iGET

Java Programming - MCQ Practice Questions

Practice free Java Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.

958 questions | 100% Free

Q.61Medium

Consider a scenario where class B extends class A. If class A has a constructor with parameters, what must class B do?

Q.62Medium

What is the relationship between an abstract class and an interface in Java 8+?

Q.63Hard

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.64Medium

Which of the following is true about interface default methods?

Q.65Hard

A real-world scenario: You're designing a banking system. Should you use an abstract class or interface for 'Account'?

Q.66Hard

What happens with exception handling in method overriding?

Q.67Medium

Which of the following correctly demonstrates composition over inheritance?

Q.68Hard

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.69Hard

In a legacy system, you find code with very deep inheritance hierarchy (5+ levels). What design problem does this indicate?

Q.70Easy

What is the access modifier of members declared in an interface?

Q.71Easy

What is the default access modifier for class members in Java if not explicitly specified?

Q.72Easy

Which keyword is used to prevent a class from being subclassed?

Q.73Easy

Can you instantiate an interface in Java?

Q.74Medium

Which of the following demonstrates proper method overloading in Java?

Q.75Medium

What will happen if you try to override a final method in a subclass?

Q.76Medium

In Java, which of the following is true about abstract classes?

Q.77Medium

What is the correct way to call a parent class constructor from a child class?

Q.78Medium

Which statement about Java interfaces is INCORRECT according to 2024 specifications?

Q.79Medium

Consider a class hierarchy: Animal -> Dog -> Puppy. A Puppy reference can access which of the following?

Q.80Medium

What is the output of this code? class Test { static int x = 10; public static void main(String[] args) { System.out.println(x++); } }