You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The purpose of this repository is to categorize my notes accordingly to the pillars of OOP. Additionally, the Java projects above all utilize OOP concepts and best practises in one way or another, while some projects may also show poor practise as well.
Table of Contents
General Knowledge
Encapsulation
Data Hiding
Information Hiding
Immutability
Access Modifiers
Defensive Copying
Inheritance
Abstraction
Polymorphism
Dynamic Dispatching
Dynamic Binding
Method Overriding
Object Relationships
Aggregation
Composition
Collections as Fields
Shallow Copy
Deep Copy
Defensive Copy
Other Key Concepts / Best Practises
Enums (Enumerated Types)
Class Invariants
JUnit
General Knowledge
Encapsulation
Inheritance
Abstraction
• What is the difference between Abstract Class and an Interface?
Interface overview
The main structural element in Java that enforces an API is an interface
An interface contains only constants and abstract methods (with addition to default methods and static methods). The abstract methods are public by default.
It has no constructors and can't directly be instantiated
A class that implements an interface must implement aLL of the methods declared in the interface (no inheritance); otherwise won't compile
A class can have multiple inheritance
Abstract Class overview
A class extends to an abstract class. (E.g., a Dog IS-A Animal)
Methods: Abstract classes can have both abstract methods and concrete methods. Subclasses can inherit these concrete methods as-is or override them, and obviously, subclasses are required to provide their own implementation of abstract methods.
Constructors: Abstract classes can have constructors, and when a subclass is instantiated, the constructor of the abstract class is called before the constructor of the subclass.
Fields: There are no limitations as to what type of field you would like to declare or initialize in an abstract class.
Inheritance (IS-A): Single inheritance; A class can only extend one abstract class. (E.g., a Dog IS-A Animal)
Instantiation You cannot create an instance of an abstract class directly using the new keyword. You can only create instances of concrete subclasses of the abstract class.
Polymorphism
Says variable husky is declared as Dog Type, but is instanceof and references an object of Husky Type.
Collections as Fields: Shallow Copy vs. Deep Copy
Object Relationships: Aggregation and Composition
• When implementing a class aimed to demonstrate an aggregation object relationship, do not do this:
Other Key Concepts / Best Practises
Enums (Enumerated Types)
Java Collections Framework
Class Invariants
JUnit Framework
Obligatory Methods
Exceptions
About
A General Overview of Advanced topics in Object-Oriented Programming by Saadaf Mohsin