iGET

Java Programming - MCQ Practice Questions

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

951 questions | 100% Free

Q.141Easy

Which access modifier allows a member to be accessed only within the same class?

Q.142Medium

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

Q.143Medium

Which statement about 'this' keyword is correct?

Q.144Medium

Consider: interface I1 { void method(); } interface I2 { void method(); } class C implements I1, I2 { public void method() { System.out.println("Method"); } } What will be the behavior?

Q.145Medium

What is method overloading?

Q.146Medium

Which of the following is true about abstract classes?

Q.147Easy

Which concept best describes the relationship between Parent and Child classes in 'class Child extends Parent'?

Q.148Hard

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

Q.149Hard

In Java, can you create an object of an abstract class?

Q.150Medium

Consider the code: abstract class Animal { abstract void sound(); void sleep() { System.out.println("Zzz"); } } class Dog extends Animal { void sound() { System.out.println("Bark"); } } What can Dog objects do?

Q.151Hard

What is the main difference between method overriding and method overloading?

Q.152Easy

Which of the following correctly describes encapsulation?

Q.153Medium

Which statement is true about the default access modifier (package-private) in Java?

Q.154Easy

What happens when you try to instantiate an interface in Java?

Q.155Easy

Which keyword is used to achieve runtime polymorphism in Java?

Q.156Medium

What is the output of the following code? class Parent { void show() { System.out.println("Parent"); } } class Child extends Parent { void show() { System.out.println("Child"); } } public class Test { public static void main(String[] args) { Parent p = new Child(); p.show(); } }

Q.157Easy

Can a class extend multiple classes in Java?

Q.158Medium

Which of the following statements about the 'final' keyword is correct?

Q.159Medium

What is the difference between 'this' and 'super' keywords?

Q.160Medium

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