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

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

Q.102Medium

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

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

Q.104Easy

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

Which of the following statements about abstract classes is TRUE?

Q.106Easy

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

Q.107Easy

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

Q.108Medium

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

Q.109Medium

Which of the following best describes encapsulation?

Q.110Medium

Which of the following is true about method overloading?

Q.111Medium

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

Q.112Hard

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

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

Q.114Medium

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

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

Q.116Hard

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

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

Q.118Hard

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

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

Q.120Easy

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