Available Questions About Java Quizzes
1. How do you declare an abstract method in Java?
public abstract void methodName();
public void methodName() { }
abstract void methodName();
public void abstract methodName();
2. What does the super keyword do in Java?
It refers to the current class’s methods
It refers to the parent class’s constructor or methods
It creates a new instance of a class
It refers to a superclass object
3. Which of the following statements about the final keyword in Java is true?
It can be used to declare constants, prevent method overriding, and inheritance
It is only used to prevent method overriding
It is used to create mutable objects
It is used to create abstract classes
4. What is the default value of a boolean variable in Java?
true
false
0
null
5. How can you create a thread in Java?
By using the Thread class’s run() method
By extending the Thread class
By implementing the Runnable interface
Both b and c
6. Which of the following is the correct way to handle exceptions in Java?
try { // code } catch (Exception e) { // handle }
try { // code } finally { // handle }
catch (Exception e) { // handle }
try { // code } throw (Exception e) { // handle }
7. Which of the following statements is true about the finally block in Java?
It executes only if an exception is thrown.
It is executed only if no exception is thrown.
It always executes regardless of whether an exception is thrown or not.
It executes only if the catch block is present.
8. How can you ensure that a class cannot be subclassed in Java?
By using the abstract keyword
By using the final keyword
By using the static keyword
By using the private keyword
9. What is the default value of an instance variable of type int in Java?
0
1
Null
Undefined
10. Which of the following is not a valid data type in Java?
int
float
integer
char