πŸ“Š JAVA
Q. Which of the following is thread-safe?
  • (A) ArrayList
  • (B) HashMap
  • (C) Vector
  • (D) HashSet
πŸ’¬ Discuss
βœ… Correct Answer: (C) Vector

Explanation: Vector is synchronized and thread-safe.

πŸ“Š JAVA
Q. Which keyword is used to refer to current object?
  • (A) this
  • (B) super
  • (C) self
  • (D) object
πŸ’¬ Discuss
βœ… Correct Answer: (A) this

Explanation: 'this' refers to the current object instance.

πŸ“Š JAVA
Q. Which exception is unchecked?
  • (A) IOException
  • (B) SQLException
  • (C) NullPointerException
  • (D) ClassNotFoundException
πŸ’¬ Discuss
βœ… Correct Answer: (C) NullPointerException

Explanation: NullPointerException is an unchecked exception.

πŸ“Š JAVA
Q. What will be the output?
Code:
System.out.println(5 + 5 + "5" + 5 + 5);
  • (A) 10555
  • (B) 10555
  • (C) 10555
  • (D) 10555
πŸ’¬ Discuss
βœ… Correct Answer: (A) 10555

Explanation: 5+5=10, then string concatenation results in 10555.

πŸ“Š JAVA
Q. What is the size of int in Java?
  • (A) 2 bytes
  • (B) 4 bytes
  • (C) Depends on OS
  • (D) 8 bytes
πŸ’¬ Discuss
βœ… Correct Answer: (B) 4 bytes

Explanation: int is always 4 bytes (32-bit) in Java, regardless of platform.

πŸ“Š JAVA
Q. Which memory area stores class metadata?
  • (A) Heap
  • (B) Stack
  • (C) Method Area
  • (D) PC Register
πŸ’¬ Discuss
βœ… Correct Answer: (C) Method Area

Explanation: Class metadata is stored in Method Area (part of JVM).

πŸ“Š JAVA
Q. What will be the output?
Code:
Integer a = 127;
Integer b = 127;
System.out.println(a == b);
  • (A) true
  • (B) false
  • (C) Compilation Error
  • (D) Runtime Error
πŸ’¬ Discuss
βœ… Correct Answer: (A) true

Explanation: Integer cache works for values -128 to 127, so both refer to same object.

πŸ“Š JAVA
Q. Which keyword is used to create a thread?
  • (A) Runnable
  • (B) Thread
  • (C) Both a and b
  • (D) process
πŸ’¬ Discuss
βœ… Correct Answer: (C) Both a and b

Explanation: Threads can be created by extending Thread or implementing Runnable.

πŸ“Š JAVA
Q. Which method is used to start a thread?
  • (A) run()
  • (B) start()
  • (C) execute()
  • (D) init()
πŸ’¬ Discuss
βœ… Correct Answer: (B) start()

Explanation: start() creates a new thread and calls run() internally.

πŸ“Š JAVA
Q. Which collection is synchronized?
  • (A) HashMap
  • (B) ArrayList
  • (C) Hashtable
  • (D) HashSet
πŸ’¬ Discuss
βœ… Correct Answer: (C) Hashtable

Explanation: Hashtable is synchronized by default.