Java Rapid-Fire Questions
1. What is the default value of a boolean variable in Java?
A) true
B) false
C) null
D) 0
**Answer:** B) false
2. Which Java keyword is used to declare a constant variable?
A) final
B) static
C) public
D) private
**Answer:** A) final
3. What is the purpose of the "super" keyword in Java?
A) To refer to the parent class
B) To refer to the child class
C) To refer to the current object
D) To refer to the static method
**Answer:** A) To refer to the parent class
4. Which Java method is used to convert a string to an integer?
A) parseInt()
B) parseDouble()
C) toString()
D) valueOf()
**Answer:** A) parseInt()
5. What is the difference between "throw" and "throws" in Java?
A) "throw" is used to declare exceptions, "throws" is used to throw exceptions
B) "throw" is used to throw exceptions, "throws" is used to declare exceptions
C) "throw" is used for checked exceptions, "throws" is used for unchecked exceptions
D) "throw" is used for unchecked exceptions, "throws" is used for checked exceptions
**Answer:** B) "throw" is used to throw exceptions, "throws" is used to declare exceptions
6. Which Java class is used to handle input/output operations?
A) Scanner
B) BufferedReader
C) InputStreamReader
D) All of the above
**Answer:** D) All of the above
7. What is the purpose of the "finally" block in Java?
A) To handle exceptions
B) To provide a default value
C) To execute code regardless of exceptions
D) To skip code execution
**Answer:** C) To execute code regardless of exceptions
8. Which Java keyword is used to declare an abstract class?
A) abstract
B) final
C) static
D) public
**Answer:** A) abstract
9. What is the difference between "== " and ".equals()" in Java?
A) "==" checks for reference equality, ".equals()" checks for value equality
B) "==" checks for value equality, ".equals()" checks for reference equality
C) "==" is used for primitive types, ".equals()" is used for reference types
D) "==" is used for reference types, ".equals()" is used for primitive types
**Answer:** A) "==" checks for reference equality, ".equals()" checks for value equality
10. Which Java method is used to sort an array?
A) sort()
B) [Link]()
C) [Link]()
D) All of the above
**Answer:** B) [Link]()