DP CompSci: Unit D

Object orientated programming

Object orientated programming

Unit D1 OOP Concepts introduces the idea of objects, classes, and the relationship between them. Unit D2 OOP Features introduces the core features of OOP as inheritance, encapsulation and polymorphism.

Current notes (used with the class of 2019):

Archived notes (used with the class of 2018):

Other teachers resources

Feel free to use these openly online resources provided by other teachers. If you come across other great online materials, let me know.

Java resources

Go to the main Java page of the website.

Revision

  1. What is OOP?
  2. What are the basic concepts of OOP? (our course only has 3 of those 4 answers)
  3. What is a class?
  4. What is an object?
  5. What is encapsulation?
  6. What is polymorphism?
  7. What is inheritance?
  8. Define a constructor?
  9. What is function overloading?
  10. What is the super keyword?
  11. What is method overriding?
  12. Differences between overloading and overriding?
  13. Difference between class and an object?
  14. What is an abstraction?
  15. What are access modifies?
  16. What is the "this" pointer?
  17. What is the default access modifier in a class?
  18. Do we require a parameter for constructors?
  19. Can a static method use nonstatic members?
  20. What is a base class, sub class and super class?

Check your answers here: https://career.guru99.com/top-50-oops-interview-questions/ and then do their OOP quiz!

Errata / additions

  • The definition of polymorphism provided in my notes/slides is incomplete. It correctly describes polymorphism by overloading, but ignores overriding. A better definition would be "Polymorphism is the concept that allows a class to have multiple implementations of the same method. Java differentiates which implementation to execute based on the combination of parameters provided (overloading) or inheritance (overriding)."
  • On the subject of relationships:
    • Aggregation (diamond on the parent end) implies a relationship where the child can exist independently of the parent. Example: Subject (parent class) and Student (child class). Delete the Subject and the Students still exist.
    • Composition (dashed line) implies a relationship where the child cannot exist independent of the parent. Example: House (parent) and Room (child). Rooms don't exist separate to a House.
    • The above two are forms of containment (hence the parent-child relationships).
    • Dependency is a weaker form of relationship and in code terms indicates that a class uses another by parameter or return type. Dependency is a form of association.