Java Full Stack Development Program
Java Full Stack Development Program
DEVELOPMENT PROGRAM
Java OOP
OUTLINE
• Object
• Object-oriented programing(OOP)
• Inheritance
• Polymorphism
• Abstract
• Encapsulation
OBJECT
• An object is a combination of data and
procedures working on the available data
• Polymorphism
• Abstraction
A PIE
• Encapsulation
INHERITANCE
• Is the ability to derive something specific from something generic.
• IS-A relationship
• Multiple
• Multilevel
• Hierarchy
• Hybrid
INHERITANCE
SINGLE INHERITANCE
MULTI LEVEL
MULTIPLE INHERITANCE
HIERARCHY INHERITANCE
• In hierarchical inheritance, more than one class
can inherit from a single class
HYBRID INHERITANCE
INHERITANCE IN JAVA
• Java supports following inheritance:
• Single
• Multi-level
• Hierarchy
• Interfaces specify what a class must do and not how. It is the blueprint
of the class.
• Why?
AGGREGATION /
COMPOSITION
• If a class have an entity reference, it is known as Aggregation
• Flexibility of aggregation
• this can be used to return the current class instance from the method.
SUPER
• A reference variable which is used to refer immediate parent class object.
• Usage
• Runtime polymorphism
COMPILE TIME VS RUNTIME
• Compile time — the instance where the code you
entered is converted to executable
• Method overloading
• a class has multiple methods having same name but different in
parameters
• Method overriding
• a method in a subclass has the same name and return
type as a method in its superclass, then the method in the
subclass is said to override the method in the superclass
• Why
• Abstract classes define partial behavior and leave the rest for the subclasses to
provide
• Abstract classes cannot be instantiated, but they can have reference variable
• If the subclasses does not override the abstract methods of the abstract class, then it
• How
• Making the fields in a class private and providing access to the fields via public methods
• Why
• Flexibility — Internal logic changes won’t affect the caller of the method
• The Object class is beneficial if you want to refer any object whose type you don't know.
Notice that parent class reference variable can refer the child class object, know as
upcasting
• Let's take an example, there is getObject() method that returns an object but it can be of
any type like Employee,Student etc, we can use Object class reference to refer that
object. For example:
• Object obj=getObject();