
Java MCQs
Quiz
•
Computers
•
Professional Development
•
Practice Problem
•
Hard
Ms STAFF
Used 2+ times
FREE Resource
Enhance your content in a minute
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
Create a free account and access millions of resources
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
GUESS THAT WORD IN CYBER!
Quiz
•
Professional Development
15 questions
Python Class 1
Quiz
•
Professional Development
15 questions
Sec+ CH.2 Review Test
Quiz
•
Professional Development
10 questions
c programming-Test 1
Quiz
•
Professional Development
10 questions
PHP QUIZ-2
Quiz
•
Professional Development
10 questions
CodeMonkey Platform Management & Resources
Quiz
•
Professional Development
10 questions
Y9 App Lab Assessment
Quiz
•
Professional Development
10 questions
Understanding AI Basics
Quiz
•
Professional Development
Popular Resources on Wayground
5 questions
This is not a...winter edition (Drawing game)
Quiz
•
1st - 5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
10 questions
Identify Iconic Christmas Movie Scenes
Interactive video
•
6th - 10th Grade
20 questions
Christmas Trivia
Quiz
•
6th - 8th Grade
18 questions
Kids Christmas Trivia
Quiz
•
KG - 5th Grade
11 questions
How well do you know your Christmas Characters?
Lesson
•
3rd Grade
14 questions
Christmas Trivia
Quiz
•
5th Grade
20 questions
How the Grinch Stole Christmas
Quiz
•
5th Grade
Discover more resources for Computers
26 questions
Christmas Movie Trivia
Lesson
•
8th Grade - Professio...
25 questions
Christmas Movies
Quiz
•
Professional Development
20 questions
Christmas Trivia
Quiz
•
Professional Development
15 questions
Fun Holiday Trivia
Quiz
•
Professional Development
25 questions
Name That Tune - Christmas
Quiz
•
Professional Development
29 questions
Christmas Song Emoji Pictionary
Quiz
•
Professional Development
9 questions
Holiday Movie Trivia
Lesson
•
Professional Development
34 questions
Winter Trivia
Quiz
•
Professional Development
