Please enable JavaScript.
Coggle requires JavaScript to display documents.
Java OOP (Java (Classes - Object Blueprints, abstract entity in software…
Java OOP
Java
Classes - Object Blueprints, abstract entity in software
-
-
-
-
-
this
refers to this class, not function like JS
-
abstract classes
-
cannot be instantiated, but can be subclassed
if a subclass doesn't acknowlege abstract methods, it must also be declared abstract
-
OOP Concepts
Abstractions - Abstractions allows us to easily interact and build objects in java. ABstractions removes the nitty gritty detail of an implementation by offering descriptive interfaces with objects to achieve the prefered outcome without having to know all the code.
-
Inheritance - inheritance allows us to build more specific or new structures on top of old ones. This enables us to build more complex or specific things without recoding everything.
-
-
-
Polymorphism allows programmers to use a single identifier to refer to different behaviors and objects based on the context.
Method Overloading (compile time - static binding) - Using different parameters, we can imply different behaviors and still have the same method be used.
Merthod Overriding (run time - dynamic bind) - If we want all animals in our animal army to bite, we can tell them all at once as they are all sub classes of animal, but each method is overloaded to do each unique bite without us having to acknowlege it.
Information Hiding / Encapsulation - Classes should keep variables private and only allow augmentation through its public interface of getters and setters. This allows the implementation details to be encapsulated and not need to be known by another programmer that wants to use this object.
-
Other OOP concepts
Association - interacting but no ownership, a relationship between some amount of classes - Student.teacher
Aggregation - has a - A team has a player, but if there's no team, the player is not gone. - weak association - players are added to the team, not created there
Composition - death relationshipt - strong aggregation - part of - a house has many rooms, but if there's no rooms, its not a house. - strong association - rooms are created in the constructor, and cant be taken out. private
-
-
Interfaces - In its most common form, an interface is a group of related methods with empty bodies
-
-
no braces on methods
implicitly abstract methods, no need to say abstract
all fields are automatically public, static, and final,
-
can have constants, but not variables
all fields are automatically public, static, and final,
-
-
Types Programming
-
OOP
Use Boxes or objects to encapsulate behaviors and states and define interfaces for how to interact with them.
-