πŸ“Š JAVA
Q. Which is not part of JVM?
  • (A) Class Loader
  • (B) JIT Compiler
  • (C) Garbage Collector
  • (D) Java Compiler
πŸ’¬ Discuss
βœ… Correct Answer: (D) Java Compiler

Explanation: Java Compiler (javac) is outside JVM.

πŸ“Š JAVA
Q. What will be the output?
Code:
System.out.println(1 << 2);
  • (A) 2
  • (B) 4
  • (C) 8
  • (D) 1
πŸ’¬ Discuss
βœ… Correct Answer: (B) 4

Explanation: Left shift multiplies by 2^n, so 1<<2 = 4.

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

Explanation: Right shift divides by 2, so 10>>1 = 5.

πŸ“Š JAVA
Q. Which keyword is used to define a constant?
  • (A) const
  • (B) static
  • (C) final
  • (D) immutable
πŸ’¬ Discuss
βœ… Correct Answer: (C) final

Explanation: final is used to declare constants.

πŸ“Š JAVA
Q. What will be the output?
Code:
String s = "abc";
s.toUpperCase();
System.out.println(s);
  • (A) ABC
  • (B) abc
  • (C) Compilation Error
  • (D) Runtime Error
πŸ’¬ Discuss
βœ… Correct Answer: (B) abc

Explanation: String is immutable, so original value remains unchanged.

πŸ“Š JAVA
Q. Which class is used for dynamic array?
  • (A) Array
  • (B) Vector
  • (C) ArrayList
  • (D) Both b and c
πŸ’¬ Discuss
βœ… Correct Answer: (D) Both b and c

Explanation: Both Vector and ArrayList provide dynamic arrays.

πŸ“Š JAVA
Q. Which method is called automatically during object destruction?
  • (A) destroy()
  • (B) finalize()
  • (C) delete()
  • (D) remove()
πŸ’¬ Discuss
βœ… Correct Answer: (B) finalize()

Explanation: finalize() was used by GC before removal (deprecated now).

πŸ“Š JAVA
Q. Which of these is marker interface?
  • (A) Runnable
  • (B) Serializable
  • (C) Comparable
  • (D) CloneableMethod
πŸ’¬ Discuss
βœ… Correct Answer: (B) Serializable

Explanation: Serializable is a marker interface.

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

Explanation: 5*5=25 then concatenation gives 525.

πŸ“Š JAVA
Q. Which exception is thrown when array index is invalid?
  • (A) NullPointerException
  • (B) ArrayIndexOutOfBoundsException
  • (C) IOException
  • (D) ArithmeticException
πŸ’¬ Discuss
βœ… Correct Answer: (B) ArrayIndexOutOfBoundsException

Explanation: Invalid array index throws ArrayIndexOutOfBoundsException.