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.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?