Published:
Last updated:

Java OOP

Authors
Time yourself:
Your progress:

00:30:00

0%

Filter by difficulty

35 of 35 questions shown

Basic OOP Concepts

1. What are the four pillars of OOP? Explain each with examples.

Junior
Flag important question
Mark as complete

2. What is the difference between a class and an object?

Junior
Flag important question
Mark as complete

3. What happens if you declare a class as final? Can it still have objects?

Junior
Flag important question
Mark as complete

4. What happens if an object is created inside a static method?

Junior
Flag important question
Mark as complete

5. How does the this keyword differ from super?

Mid-level
Flag important question
Mark as complete

Inheritance

Free preview complete

You’ve reached the end of the free preview

Get every remaining question and complete answer, plus progress tracking across the full Interview Question Library.

  • 30 more questions and complete answers in this topic
  • Full access to every interview topic
  • Progress tracking and question flags
  • New questions and improvements during your subscription

Full access from

$12/month

No long-term commitment. Cancel whenever you want.

6. Can a constructor be inherited in Java? Why or why not?

JuniorPaid Question

7. What happens if a subclass overrides a method but calls the super version as well?

JuniorPaid Question

8. Can a subclass call a private method of the superclass?

JuniorPaid Question

Polymorphism

9. What is polymorphism, and how does it work in Java?

Mid-levelPaid Question

10. Can you override a static method in Java?

JuniorPaid Question

11. How does Java handle method overloading when the arguments involve inheritance (e.g., Object vs. String)?

Mid-levelPaid Question

12. How does Java decide which overridden method to call when the reference type and object type differ?

Mid-levelPaid Question

Abstraction

13. What is abstraction, and how is it implemented in Java?

JuniorPaid Question

14. How do default methods in interfaces affect abstraction in Java 8+?

Mid-levelPaid Question

15. Can an abstract class have a constructor, and when is it called?

JuniorPaid Question

Encapsulation

16. How does encapsulation improve code maintainability?

Mid-levelPaid Question

17. Why should instance variables in a class be private?

Mid-levelPaid Question

18. Can you enforce encapsulation without getters and setters?

Mid-levelPaid Question

Interfaces and Abstract Classes

19. What is the difference between an interface and an abstract class?

Mid-levelPaid Question

20. How does Java handle the diamond problem in interfaces?

Mid-levelPaid Question

21. Can an interface extend another interface and how is it useful?

JuniorPaid Question

22. Can an interface contain static methods? How are they accessed?

JuniorPaid Question

Composition and Aggregation

23. What is the difference between composition and aggregation?

Mid-levelPaid Question

24. How is dependency injection related to composition?

Mid-levelPaid Question

Constructors and Overloading

25. What happens if a constructor calls another constructor using this() and has code before the call?

JuniorPaid Question

26. Can a constructor throw an exception? How would you handle it?

Mid-levelPaid Question

27. What happens if a subclass doesn’t explicitly call a superclass constructor?

JuniorPaid Question

Method Overloading and Overriding

28. What is the difference between method overloading and method overriding?

Mid-levelPaid Question

29. Can you override a private method in Java?

JuniorPaid Question

30. Can a method with throws clause in the superclass be overridden without it in the subclass?

JuniorPaid Question

Design Principles in OOP

31. What is the SOLID principle in OOP?

JuniorPaid Question

32. How does the Single Responsibility Principle help in writing maintainable code?

Mid-levelPaid Question

33. Can you explain the Open/Closed Principle with an example?

Mid-levelPaid Question

34. How do Liskov Substitution and Interface Segregation principles influence your choice of inheritance or interfaces?

Mid-levelPaid Question

35. How can you ensure a method follows the Dependency Inversion Principle?

Mid-levelPaid Question