πŸ“Š JAVA
Q. Which of these is used to handle exceptions?
  • (A) try-catch
  • (B) if-else
  • (C) for loop
  • (D) switch
πŸ’¬ Discuss
βœ… Correct Answer: (A) try-catch

Explanation: Exceptions are handled using try-catch blocks in Java.

πŸ“Š JAVA
Q. Which collection does not allow duplicates?
  • (A) List
  • (B) Set
  • (C) Map
  • (D) Queue
πŸ’¬ Discuss
βœ… Correct Answer: (B) Set

Explanation: Set does not allow duplicate elements.

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

Explanation: Strings are immutable. concat() returns a new string but does not modify the original.

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

Explanation: The 'final' keyword prevents class inheritance.

πŸ“Š JAVA
Q. Which interface is implemented by ArrayList?
  • (A) Set
  • (B) Map
  • (C) List
  • (D) Queue
πŸ’¬ Discuss
βœ… Correct Answer: (C) List

Explanation: ArrayList implements the List interface.

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

Explanation: String concatenation occurs first, resulting in AB1020.

πŸ“Š JAVA
Q. Which of these is not a primitive type?
  • (A) int
  • (B) float
  • (C) String
  • (D) boolean
πŸ’¬ Discuss
βœ… Correct Answer: (C) String

Explanation: String is a class, not a primitive type.

πŸ“Š JAVA
Q. What is method overloading?
  • (A) Same method name with different parameters
  • (B) Same method name and same parameters
  • (C) Different method names
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (A) Same method name with different parameters

Explanation: Method overloading means same method name but different parameter lists.

πŸ“Š JAVA
Q. Which keyword is used for abstraction?
  • (A) abstract
  • (B) interface
  • (C) Both a and b
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (C) Both a and b

Explanation: Both abstract classes and interfaces provide abstraction.

πŸ“Š JAVA
Q. What will be the output?
Code:
int a = 10;
if(a = 20) {
 System.out.println("Hello");
}
  • (A) Hello
  • (B) Compilation Error
  • (C) Runtime Error
  • (D) No Output
πŸ’¬ Discuss
βœ… Correct Answer: (B) Compilation Error

Explanation: Assignment inside if condition is invalid for boolean in Java.