Java MCQ

Test your Java knowledge with 100 multiple choice questions covering fundamentals to advanced concepts, with instant feedback and explanations.

100 Questions 41 Beginner 39 Intermediate 20 Advanced
1

What does JVM stand for?

2

Which of the following is NOT a Java primitive type?

3

What is the correct signature of the main method in Java?

4

Which keyword is used to create an object in Java?

5

What is the default value of an int variable in Java?

6

Which symbol is used for single-line comments in Java?

7

What keyword is used for inheritance in Java?

8

Which keyword is used to implement an interface?

9

What is the superclass of all Java classes?

10

What does the final keyword do when applied to a variable?

11

What is the size of an int in Java?

12

What is a constructor?

13

What does method overloading mean?

14

Which access modifier makes a member visible only within its class?

15

What does the static keyword mean on a method?

16

Which package is automatically imported in every Java program?

17

What is the output of: System.out.println(10 / 3)?

18

Which loop is guaranteed to execute at least once?

19

What does the instanceof operator do?

20

What is an abstract class?

21

How do you print to the console in Java?

22

What is the boolean default value in Java?

23

Which of these is a valid Java identifier?

24

What is an array in Java?

25

What does JDK stand for?

26

Which operator is used to compare two values in Java?

27

What is the range of the byte data type in Java?

28

What is method overriding?

29

Which collection class allows duplicate elements and maintains insertion order?

30

What does the void return type mean?

31

Which keyword prevents a class from being subclassed?

32

What is the ternary operator in Java?

33

What exception is thrown when an array index is out of bounds?

34

How do you declare a constant in Java?

35

What is the length of a String s = "Hello"?

36

What is autoboxing in Java?

37

Which of these correctly creates an array of 5 integers?

38

What does the this keyword refer to?

39

What is the output of: System.out.println("5" + 3)?

40

Which exception is the parent of all checked exceptions?

41

What does the super keyword do?

1

What is the difference between == and equals() when comparing Strings?

2

What is the purpose of the try-catch-finally block?

3

What is the difference between ArrayList and LinkedList?

4

What is a checked exception?

5

What does the synchronized keyword do?

6

What is the purpose of the interface keyword?

7

What is the difference between HashMap and TreeMap?

8

What is a lambda expression in Java 8+?

9

What does the volatile keyword guarantee?

10

Which method must be implemented by a class implementing the Runnable interface?

11

What is the purpose of the Optional class in Java 8?

12

What is the Stream API used for in Java 8?

13

What is the difference between an abstract class and an interface?

14

What is the purpose of the @Override annotation?

15

What is the difference between throw and throws?

16

What is the significance of the hashCode() contract?

17

What is garbage collection in Java?

18

What is the purpose of the Comparable interface?

19

What does String.intern() do?

20

What is the difference between final, finally, and finalize?

21

What is a functional interface?

22

What is the purpose of Collections.unmodifiableList()?

23

What does the transient keyword do?

24

What is the difference between Iterator and ListIterator?

25

What happens when you catch a parent exception type before a child type?

26

What is method chaining?

27

What does Collections.sort() use internally by default?

28

What is the purpose of the Executor framework?

29

What is a deadlock in Java?

30

What is the difference between StringBuilder and StringBuffer?

31

What is the Singleton design pattern?

32

What is the purpose of the Iterable interface?

33

What does AtomicInteger provide over volatile int?

34

What is the output of Integer.parseInt("10", 2)?

35

Which Java collection is backed by a hash table and maintains insertion order?

36

What does the default keyword in a Java 8 interface do?

37

What is the difference between String.format() and StringBuilder for repeated concatenation?

38

What is the purpose of the java.util.concurrent package?

39

What is the try-with-resources statement?