OOP Java
by Ventsislav Draganov
1. Abstract Class
1.1. Mix between interface and concrete class
1.2. Can not be instantiate
1.3. Keeps the data and internal methods hidden for the outside world
2. Class
2.1. Blueprint that describes the Object
2.2. PascalCase Name
2.3. Access Modifier
2.3.1. Public, Private, Package-Private(fields and methods can be protected - subclass in different package have access to them )
2.4. Has Constructor
2.4.1. Default -Initialise all fields with default values
2.4.2. Overload with key word this - first statement in the constructor
2.5. Has State (Attributes/Fields/Properties)
2.5.1. Class Variable - Static
2.5.2. Local Variable - defined inside methods
2.5.3. Instance Variable - variables within a class but outside any method
2.6. Has Behaviour (Methods)
2.6.1. Static Methods
2.6.1.1. static methods can access all static variables and other static methods
2.6.1.2. Static methods cannot access instance variables and instance methods directly- they need some object reference to do so
2.6.2. Overload Methods
2.6.3. Override Methods
2.6.4. Instance Methods
2.6.4.1. Getter Methods - accessors
2.6.4.2. Setter Methods - mutators
2.6.4.3. Instance methods can directly access both instance methods and instance variables
2.6.4.4. Instance methods can also access static variables and static methods directly
2.6.5. CamelCase Name
3. Object
3.1. Declaration − A variable declaration with a variable name with an object type.
3.2. Instantiation − The 'new' keyword is used to create the object
3.3. Initialization − The 'new' keyword is followed by a call to a constructor. This call initializes the new object
3.4. .(dot) operator access the state and the behaviour
4. Enums
4.1. Enum is like Class
4.2. Implements Interface
4.3. Can not be Inherite
4.4. Default methods - toString(), values(), valueOf("string")
4.5. Can have constructor, fields, methods, abstract methods(they have to be override by each enum)
4.6. EnumMap<EnumName, String> enumMap = new EnumMap<EnumName, String>(EnumName.class);
4.7. EnumSet<EnumName> enumSet = EnumSet.of(place the enums here);
5. Interface
5.1. Functional Interface - Lambda
5.2. Extending more that one class
5.3. Class implements Interface
5.4. it is used for polymorphism
5.5. Has fields - just name and methods - just body
6. Composition
6.1. Class-Class "has-a" relationship
6.2. Class is a Field
7. Inheritance
7.1. Superclass-Subclass "is-a" relationship
7.2. Subclass inherited the Superclass non private Fields and Methods - using extends keyword
7.3. Subclass can call the Superclass constructor, methods and fields with the keyword super
7.4. java use dynamic-binding when we calls a override method
7.5. Final or Private Class can not be Inherit
8. Encapsulation
8.1. Provides the security
8.2. Keeps the data and internal methods hidden for the outside world
9. Polymorphism
9.1. Мeans "many forms"
9.2. Every class that extends the same class can be define under the superclass type
9.3. calls only the superclass methods or use only superclass fields. If the subclass override a superclass method, java use dynamic-binding and calls the subclass method
10. Abstraction
10.1. System of objects that interact with each other
10.2. Provides advantage of code reuse
10.3. Breaking the Objects into more manageable pieces
10.4. Use the functionality of the class without knowing the implementation