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.1Easy

Which of the following is NOT a pillar of Object-Oriented Programming?

Q.2Medium

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

Q.3Easy

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

Q.4Easy

What will be the output? class Parent { void show() { System.out.println("Parent"); } } class Child extends Parent { void show() { System.out.println("Child"); } } parent obj = new Child(); obj.show();

Q.5Medium

Which of the following statements about abstract classes is TRUE?

Q.6Easy

What is the purpose of the 'super' keyword in Java?

Q.7Easy

Which interface in Java represents a collection that does not allow duplicate elements?

Q.8Medium

What will happen when you try to instantiate an interface in Java?

Q.9Medium

Which of the following best describes encapsulation?

Q.10Medium

Which of the following is true about method overloading?

Q.11Medium

What is the correct way to prevent a class from being inherited in Java?

Q.12Hard

What will be the output? interface A { void show(); } class B implements A { public void show() { System.out.println("B"); } } class C extends B { public void show() { System.out.println("C"); } } A obj = new C(); obj.show();

Q.13Easy

Which of the following correctly describes the 'this' keyword?

Q.14Medium

What is the output? class A { A() { System.out.println("A"); } } class B extends A { B() { super(); System.out.println("B"); } } public class Test { public static void main(String[] args) { new B(); } }

Q.15Easy

Which keyword is used to make a variable immutable in Java?

Q.16Hard

What will be the output? class Test { int x = 5; { x = 10; } Test() { x = 15; } public static void main(String[] args) { Test t = new Test(); System.out.println(t.x); } }

Q.17Medium

Which of the following statements about 'instanceof' operator is correct?

Q.18Hard

What is the output? interface I1 { void method1(); } interface I2 extends I1 { void method2(); } class C implements I2 { public void method1() { System.out.println("M1"); } public void method2() { System.out.println("M2"); } } public class Test { public static void main(String[] args) { I1 obj = new C(); obj.method2(); } }

Q.19Easy

Which of the following access modifiers allows a variable to be accessed only within the same class?

Q.20Easy

In Java, which keyword is used to create a reference variable that cannot point to a different object after initialization?