Graded A+
A final class in Java can be extended by another class.
✔✔False
A static method can access instance variables of a class.
✔✔False
The equals() method must always be overridden when overriding hashCode().
✔✔True
Java supports multiple inheritance through classes.
✔✔False
An interface in Java can have both abstract methods and default methods.
✔✔True
1
,A constructor in Java can have a return type.
✔✔False
The super keyword is used to refer to the parent class constructor or methods.
✔✔True
A Java method can have multiple return statements.
✔✔True
The finally block in exception handling is always executed.
✔✔True
A try block can exist without a catch block if a finally block is present.
✔✔True
All methods in an abstract class must be abstract.
✔✔False
2
,An interface can extend multiple interfaces in Java.
✔✔True
A Java enum can have constructors and methods.
✔✔True
The this keyword can be used to call a static method.
✔✔False
A private method in a class can be accessed by its subclasses.
✔✔False
The continue statement immediately terminates the loop.
✔✔False
A switch statement in Java can use String values as case labels.
✔✔True
3
, A volatile variable ensures that its value is read from main memory, not from a thread’s cache.
✔✔True
A synchronized method allows multiple threads to execute it simultaneously.
✔✔False
The transient keyword prevents a variable from being serialized.
✔✔True
An instance of an abstract class can be created directly.
✔✔False
A Java program will always terminate if an exception occurs.
✔✔False
The do-while loop executes at least once, even if the condition is false.
✔✔True
4