Published on

Java OOP

Authors
Time yourself:
Your progress:

00:30:00

0%

Basic OOP Concepts

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

5. How does the this keyword differ from super?

Flag important question
Mark as complete

Inheritance

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

Polymorphism

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

Flag important question
Mark as complete

10. Can you override a static method in Java?

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

Abstraction

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

Encapsulation

16. How does encapsulation improve code maintainability?

Flag important question
Mark as complete

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

Flag important question
Mark as complete

18. Can you enforce encapsulation without getters and setters?

Flag important question
Mark as complete

Interfaces and Abstract Classes

19. Can you enforce encapsulation without getters and setters?

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

Composition and Aggregation

23. What is the difference between composition and aggregation?

Flag important question
Mark as complete

24. How is dependency injection related to composition?

Flag important question
Mark as complete

Constructors and Overloading

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

Method Overloading and Overriding

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

Flag important question
Mark as complete

29. Can you override a private method in Java?

Flag important question
Mark as complete

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

Flag important question
Mark as complete

Design Principles in OOP

31. What is the SOLID principle in OOP?

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete