1. Which of the following is true about Java?
A) Java is platform-dependent, meaning it can only run on specific operating
systems.
B) Java programs need to be compiled into machine code before they can
run.
C) Java is platform-independent due to the use of the Java Virtual Machine
(JVM).
D) Java is only used for server-side programming.
Answer: C) Java is platform-independent due to the use of the Java Virtual
Machine (JVM).
2. Which of the following is used to handle exceptions in Java?
A) try-catch
B) throw-catch
C) if-else
D) assert-throw
Answer: A) try-catch
3. What does the static keyword mean in Java?
A) The member belongs to the class, rather than instances of the class.
B) The member cannot be overridden by subclasses.
C) The method can only be called within the constructor of the class.
D) The member is constant and cannot be changed.
Answer: A) The member belongs to the class, rather than instances of the
class.
4. What is the purpose of the super keyword in Java?
A) It is used to call a parent class constructor.
B) It is used to refer to an instance variable.
C) It is used to stop the execution of a program.
D) It is used to inherit another class in Java.
Answer: A) It is used to call a parent class constructor.
5. Which of the following is true about the final keyword in Java?
A) final can be applied to variables, methods, and classes, and it prevents
modification.
B) final only prevents method overriding, not variable assignment.
C) final only prevents variable assignment, not method overriding.
D) final can only be applied to variables, but not methods or classes.
Answer: A) final can be applied to variables, methods, and classes, and it
prevents modification.
6. Which of the following is the correct syntax for a method that returns an
integer value in Java?
A) int methodName() { }
B) integer methodName() { }
C) void methodName() { return 0; }
D) integer methodName() { return 0; }
Answer: A) int methodName() { }
7. Which of the following collections does not allow duplicate elements in
Java?
A) ArrayList
B) HashSet
C) LinkedList
D) Vector
Answer: B) HashSet
8. What is the size of an int in Java?
A) 16 bits
B) 32 bits
C) 64 bits
D) 128 bits
Answer: B) 32 bits
9. Which of the following is used to import Java packages?
A) import <package-name>;
B) use <package-name>;
C) include <package-name>;
D) require <package-name>;
Answer: A) import <package-name>;
10. What does the this keyword refer to in Java?
A) It refers to the current class itself.
B) It refers to the parent class.
C) It refers to the current method.
D) It refers to a static member of the class.
Answer: A) It refers to the current class itself.