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 feature of Java ensures that a child class can have a method with a wider return type than the parent class?
What is the key difference between composition and inheritance in object design?
You need to create a class that provides common functionality for all database operations (insert, update, delete). What is the best approach?
In Java 16+, which sealed class feature allows you to restrict which classes can extend a class?
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();
Which of the following correctly implements the Factory Design Pattern principle in OOP?
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?