
Java MCQs
Authored by Ms STAFF
Computers
Professional Development
Used 2+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following will cause a compile-time error?
class Demo {
static int x = 10;
int y = 5;
static void test() {
System.out.println(y);
}
}
Error due to static method accessing y
No error
Error in variable declaration
Error in class declaration
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of these is true about constructors in Java?
Constructors must have a return type
Constructors can be inherited
Constructors can be overloaded
You must define at least one constructor
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which is the parent class of all classes in Java?
Object
Class
SuperClass
Base
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What happens if you do not provide a constructor in a class?
Compile error
Java provides a default constructor
Object cannot be created
Class won't compile
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output?
public class Demo {
static {
System.out.println("Static block");
}
public static void main(String[] args) {
System.out.println("Main method");
}
}
Main method
Static block
Static block
Main method
Compile error
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which block runs first when a class is loaded?
Constructor
Static block
Main method
Instance block
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What happens if we try to access a non-static variable from a static method?
It compiles and runs normally
Compile-time error
Runtime exception
It automatically converts to static
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
FP2: 02 - STRINGS
Quiz
•
Professional Development
12 questions
Javascript Avanzado ft-22b Grupo 5
Quiz
•
Professional Development
10 questions
A+ Core 1 Printer Troubleshooting
Quiz
•
University - Professi...
11 questions
ВебДиз4
Quiz
•
Professional Development
10 questions
Power BI Essentials
Quiz
•
Professional Development
7 questions
Review Class 11
Quiz
•
Professional Development
10 questions
CEH Pre Assessment
Quiz
•
Professional Development
8 questions
Windows Updates
Quiz
•
9th Grade - Professio...
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
Discover more resources for Computers
10 questions
How to Email your Teacher
Quiz
•
Professional Development
6 questions
3RD GRADE DECLARATION OF INDEPENDENCE EXIT TICKET
Quiz
•
Professional Development
19 questions
Black History Month Trivia
Quiz
•
6th Grade - Professio...
22 questions
Multiplying Exponents with the Same Base
Quiz
•
9th Grade - Professio...
40 questions
Flags of the World
Quiz
•
KG - Professional Dev...