26. What does the hashCode() method of an object represent?
- A) A unique identifier for the object
- B) A hash value used in collections like HashMap
- C) A random value for the object
- D) The object’s memory address
27. What will be the output of the following code?
String str1 = "Hello";
String str2 = "Hello";
System.out.println(str1 == str2);
- A) true
- B) false
- C) Compilation error
- D) Runtime exception
28. Which of these operators is used for bitwise AND in Java?
29. In Java, the switch statement can operate on which of these data types?
- A) int, char, byte, short, enum, String
- B) float, char, boolean, String
- C) double, long, char, String
- D) boolean, int, double, String
30. Which method is automatically called when an object is garbage collected?
- A) finalize()
- B) clean()
- C) destroy()
- D) remove()
31. What is the purpose of the super keyword in Java?
- A) To refer to the current class
- B) To refer to the parent class
- C) To create a new object
- D) To terminate the program
32. Which of the following classes is synchronized in Java?
- A) ArrayList
- B) Vector
- C) LinkedList
- D) HashMap
33. Which method in the Thread class is used to check if a thread is alive?
- A) isAlive()
- B) checkAlive()
- C) alive()
- D) threadStatus()
34. What is the correct syntax for a lambda expression in Java?
- A) (parameter) -> expression
- B) parameter -> {expression}
- C) (parameter) => expression
- D) () -> expression
35. Which exception is thrown when a thread is waiting, sleeping, or doing some other operation and is interrupted?
- A) InterruptedException
- B) IllegalStateException
- C) ArithmeticException
- D) IOException
Java MCQ Questions with Answers PDF
2 thoughts on “Java Aptitude MCQ Questions with Answers for Freshers”