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

Consider the code: class A { A() { System.out.println("A"); } } class B extends A { B() { super(); System.out.println("B"); } } What will be printed when 'new B()' is executed?

Q.142Easy

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

Q.143Medium

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

Q.144Medium

Which statement about 'this' keyword is correct?

Q.145Medium

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

What is method overloading?

Q.147Medium

Which of the following is true about abstract classes?

Q.148Easy

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

Q.149Hard

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

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

Q.151Medium

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

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

Q.153Easy

Which of the following correctly describes encapsulation?

Q.154Medium

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

Q.155Easy

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

Q.156Easy

Which keyword is used to achieve runtime polymorphism in Java?

Q.157Medium

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

Can a class extend multiple classes in Java?

Q.159Medium

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

Q.160Medium

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