One Pager Cheat Sheet
- We will be learning about Advanced Practices in Object-Orientated Programming today, which are essential for understanding and using OOP.
- Access level modifiers are used to determine which classes can use defined fields or invoke specific methods in order to maintain access control for members of a class.
- All
publicattributes and class methods should be used as sparingly as possible, and there should only be onepublicclass per file in Java, where the file name must be the same as its class name. - Classes, methods, or attributes without any access keyword defined are
package-private, allowing any class inside the same package to access them, but no other class outside the package can. - Square can access
protectedmethods and attributes of its ancestor classes in the inheritance hierarchy. - The most restrictive access modifier
privateshould be used to hide data from the outside world, leading to fewer bugs later on. - In all OOP-supported programming languages,
thisor another special keyword must be used to access the "self" object from within a class in order to access attributes or pass an object to an outside function. - The current object is referenced using the
thiskeyword, which in this context refers to an instance of theAclass, and should be used to access thetextproperty of the instance viathis.text. - Classes can access methods of their superclass using the
superkeyword. - The use of
superenables access to methods of a class' superclass and allows to access any superclass' method with the use ofsuper.super.method(). - Using Method Chaining, multiple functions can be called on an object in a single statement, returning the object to allow function calls to be
chainedtogether. - Overriding occurs between the superclass and subclass, while overloading is done within the same class and differs in the function signature.
- You can
upcastand/ordowncastan object within its inheritance hierarchy, but it is bad practice to downcast unless necessary, and casting to classes outside of the hierarchy requires aModelMapper. - Becoming a master of Object-Oriented Programming (OOP) involves learning about
abstractclasses, multiple inheritance, and interfaces, as well as making OOP design decisions and creating UML diagrams.


