Consider a scenario where class B extends class A. If class A has a constructor with parameters, what must class B do?
Q.162Medium
What is the relationship between an abstract class and an interface in Java 8+?
Q.163Hard
What does the following code output?
class A { static void display() { System.out.println("A"); } }
class B extends A { static void display() { System.out.println("B"); } }
public class Test { public static void main(String[] args) { A ref = new B(); ref.display(); } }
Q.164Medium
Which of the following is true about interface default methods?
Q.165Hard
A real-world scenario: You're designing a banking system. Should you use an abstract class or interface for 'Account'?
Advertisement
Q.166Hard
What happens with exception handling in method overriding?
Q.167Medium
Which of the following correctly demonstrates composition over inheritance?
Q.168Hard
What is the output of the following code?
interface I1 { default void show() { System.out.println("I1"); } }
interface I2 { default void show() { System.out.println("I2"); } }
class C implements I1, I2 { public void show() { I1.super.show(); } public static void main(String[] args) { new C().show(); } }
Q.169Hard
In a legacy system, you find code with very deep inheritance hierarchy (5+ levels). What design problem does this indicate?
Q.170Easy
What is the access modifier of members declared in an interface?
Q.171Easy
What is the default access modifier for class members in Java if not explicitly specified?
Q.172Easy
Which keyword is used to prevent a class from being subclassed?
Q.173Easy
Can you instantiate an interface in Java?
Q.174Medium
Which of the following demonstrates proper method overloading in Java?
Q.175Medium
What will happen if you try to override a final method in a subclass?
Q.176Medium
In Java, which of the following is true about abstract classes?
Q.177Medium
What is the correct way to call a parent class constructor from a child class?
Q.178Medium
Which statement about Java interfaces is INCORRECT according to 2024 specifications?
Q.179Medium
Consider a class hierarchy: Animal -> Dog -> Puppy. A Puppy reference can access which of the following?
Q.180Medium
What is the output of this code?
class Test {
static int x = 10;
public static void main(String[] args) {
System.out.println(x++);
}
}