- Published:
- Last updated:
Java OOP
- Authors
- Name
- Lucian Oprea
- @LucianDSA_
00:30:00
Filter by difficulty
35 of 35 questions shown
Basic OOP Concepts
⏷ 1. What are the four pillars of OOP? Explain each with examples.
⏷ 2. What is the difference between a class and an object?
⏷ 3. What happens if you declare a class as final? Can it still have objects?
⏷ 4. What happens if an object is created inside a static method?
⏷ 5. How does the this keyword differ from super?
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?
⏷ 7. What happens if a subclass overrides a method but calls the super version as well?
⏷ 8. Can a subclass call a private method of the superclass?
Polymorphism
⏷ 9. What is polymorphism, and how does it work in Java?
⏷ 10. Can you override a static method in Java?
⏷ 11. How does Java handle method overloading when the arguments involve inheritance (e.g., Object vs. String)?
⏷ 12. How does Java decide which overridden method to call when the reference type and object type differ?
Abstraction
⏷ 13. What is abstraction, and how is it implemented in Java?
⏷ 14. How do default methods in interfaces affect abstraction in Java 8+?
⏷ 15. Can an abstract class have a constructor, and when is it called?
Encapsulation
⏷ 16. How does encapsulation improve code maintainability?
⏷ 17. Why should instance variables in a class be private?
⏷ 18. Can you enforce encapsulation without getters and setters?
Interfaces and Abstract Classes
⏷ 19. What is the difference between an interface and an abstract class?
⏷ 20. How does Java handle the diamond problem in interfaces?
⏷ 21. Can an interface extend another interface and how is it useful?
⏷ 22. Can an interface contain static methods? How are they accessed?
Composition and Aggregation
⏷ 23. What is the difference between composition and aggregation?
⏷ 24. How is dependency injection related to composition?
Constructors and Overloading
⏷ 25. What happens if a constructor calls another constructor using this() and has code before the call?
⏷ 26. Can a constructor throw an exception? How would you handle it?
⏷ 27. What happens if a subclass doesn’t explicitly call a superclass constructor?
Method Overloading and Overriding
⏷ 28. What is the difference between method overloading and method overriding?
⏷ 29. Can you override a private method in Java?
⏷ 30. Can a method with throws clause in the superclass be overridden without it in the subclass?
Design Principles in OOP
⏷ 31. What is the SOLID principle in OOP?
⏷ 32. How does the Single Responsibility Principle help in writing maintainable code?
⏷ 33. Can you explain the Open/Closed Principle with an example?
⏷ 34. How do Liskov Substitution and Interface Segregation principles influence your choice of inheritance or interfaces?
⏷ 35. How can you ensure a method follows the Dependency Inversion Principle?