iGET

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

Q.21Hard

Which feature of Java ensures that a child class can have a method with a wider return type than the parent class?

Q.22Hard

What is the key difference between composition and inheritance in object design?

Q.23Hard

You need to create a class that provides common functionality for all database operations (insert, update, delete). What is the best approach?

Q.24Hard

In Java 16+, which sealed class feature allows you to restrict which classes can extend a class?

Q.25Hard

A system has classes: Vehicle -> Car -> ElectricCar. If Vehicle.start() is overridden in Car and again in ElectricCar, what is the output of: Vehicle v = new ElectricCar(); v.start();

Q.26Hard

Which of the following correctly implements the Factory Design Pattern principle in OOP?

Q.27Hard

In a banking system, Account is a parent class with method withdraw(). SavingsAccount and CurrentAccount both override it. A programmer writes: List<Account> accounts = new ArrayList<>(); accounts.add(new SavingsAccount()); accounts.add(new CurrentAccount()); for(Account a : accounts) a.withdraw(1000); Which concept is primarily demonstrated here?