What is the is a and has a relation ship in oops concept in
java?

Answer Posted / kishor patil

Inheritance defines the relationship is-a(also called the
superclass-subclass relationship) between a superclass and
it's subclasses. This means that an object of a subclass
is-a superclass object,and can be used wherever an object
the of superclass can be used.

For EX-Suppose person is a superclass of Teacher
class,Driver class,Engineer class.

Here we can say every Teacher is person,Every Driver is
a person,And Every Engineer is a person ,but vice -versa
not true i.e Every person can not be teacher or driver or
Engineer.


Aggregation Defines the relationship has-a(also called
whole-part relatioship)between an instance of class and
it's constituents(also called parts).Aggregation comprises
the usage of objects.

We can say that a composite object built from the
constituent objects that are its parts .


For EX- Vehical is class.

vehical has a wheel,
vehical has a engine,
vehical has a stearing ,
vehical has a gear.


means vehical has a parts like
wheel,engine ,stearing ,gear.

Is This Answer Correct ?    24 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a file pointer?

504


What is method and methodology?

597


define polymorphism in java

620


What is variable and rules of variable?

502


What is sizeof in java?

546






How big is a pointer?

544


What are the different conditional statements?

547


What is the difference between superclass and subclass?

533


What is preflight request?

518


What is application system?

491


Explain the difference between jvm and jre?

550


What is Java Shutdown Hook?

602


What is a class object?

491


What is generic type?

559


What is the internal implementation of set in java?

491