Java Programming - MCQ Practice Questions
Java interviews and campus tests lean heavily on object oriented behaviour rather than API recall. This set covers inheritance and polymorphism, interfaces and abstract classes, the collections framework, exception handling, multithreading, string handling, and JVM basics such as garbage collection. Output based questions are included because they expose the gaps that theory questions hide.
951 questions | 100% Free
In Java, if a parent class has a method void display() and a child class overrides it as void display(int x), what is this called?
Consider a scenario where you have an interface Shape with a method calculateArea(). You implement this in classes Circle and Rectangle. Which OOP concept is being demonstrated?
What will be printed when this code executes?
class A { int x = 5; }
class B extends A { int x = 10; }
public class Test {
public static void main(String[] args) {
A a = new B();
System.out.println(a.x);
}
}
Which of the following statements about 'this' keyword in Java is INCORRECT?
In Java, a class can implement multiple interfaces but can extend only one class. This design choice primarily supports which principle?
In Java, when you override a method from a parent class, which of the following is NOT a valid reason to use the @Override annotation?