INSTANCE,Java Class Hierarch, Inheritance In JAVA


 INSTANCE




• Instance is an Object of a class which is an entity with its own attribute values and methods.


 Creating an Instance : 


   ClassName refVariable;

  refVariable = new Constructor();


                or


ClassName refVariable = new Constructor();



Java Class Hierarchy


• In Java, class “Object” is the base class to all other classes

– If we do not explicitly say extends in a new class definition,

it implicitly extends Object


– The tree of classes that extend from Object and all of its

subclasses are is called the class hierarchy


– All classes eventually lead back up to Object


– This will enable consistent access of objects of different

classes.



Inheritance



• Methods allows to reuse a sequence of statements


• Inheritance allows to reuse classes by deriving a new class

from an existing one


• The existing class is called the parent class, or superclass, or

base class


• The derived class is called the child class or subclass.


• The child class inherits characteristics of the parent class(i.e

the child class inherits the methods and data defined for the

parent class


• Inheritance relationships are often shown graphically

in a class diagram, with the arrow pointing to the

parent class

Post a Comment (0)
Previous Post Next Post