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
Which keyword is used to make a variable immutable in Java?
Which of the following access modifiers allows a variable to be accessed only within the same class?
In Java, which keyword is used to create a reference variable that cannot point to a different object after initialization?
What is the primary purpose of using the 'super' keyword in Java?
In Java OOP, which principle ensures that internal details of a class are hidden from the outside world?
Which of the following correctly describes the relationship between a class and an interface?
What will be the output of the following code? class Parent { void display() { System.out.println("Parent"); } } class Child extends Parent { void display() { System.out.println("Child"); } } public class Test { public static void main(String[] args) { Parent p = new Child(); p.display(); } }
What is the primary purpose of the 'super' keyword in Java?
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?
Which access modifier allows a member to be accessed only within the same class?
Which concept best describes the relationship between Parent and Child classes in 'class Child extends Parent'?
Which of the following correctly describes encapsulation?
What happens when you try to instantiate an interface in Java?
Which keyword is used to achieve runtime polymorphism in Java?
Can a class extend multiple classes in Java?
What is the access modifier of members declared in an interface?
What is the default access modifier for class members in Java if not explicitly specified?
Which keyword is used to prevent a class from being subclassed?
Can you instantiate an interface in Java?
What is the default access modifier for a class member in Java if no modifier is specified?