filmov
tv
RelationShip In Java Part-1 ||Java Tutorial for RelationShip

Показать описание
Relationship in Java:-
=====================
• Type of relationship always makes to understand how to reuse
the feature from one class to another class.
• Based on reusing the data members from one class to another
class in JAVA we have three types of relationships. They are is-
a relationship, has-a relationship and uses-a relationship.
• In Java programming we have three types of relationship they
are.
• Is-A Relationship
• Has-A Relationship
• Uses-A Relationship
• In Is-A relationship one class is obtaining the features of
another class by using inheritance concept with extends
keywords.
In a IS-A relationship there exists logical memory space.
Class Animal
{
}
public class Mammal extends Animal
{
}
Public class Dog extends Mammal
{
}
Public class Elephant extends Mammal
{
}
IS-A is a way of saying: this object is a type of that object.
Mammal IS-A Animal
Dog IS-A Mammal: Hence Dog IS-A Animal as well.
Elephant IS-A Mammal: Hence Elephant IS-A Animal as well.
=====================
• Type of relationship always makes to understand how to reuse
the feature from one class to another class.
• Based on reusing the data members from one class to another
class in JAVA we have three types of relationships. They are is-
a relationship, has-a relationship and uses-a relationship.
• In Java programming we have three types of relationship they
are.
• Is-A Relationship
• Has-A Relationship
• Uses-A Relationship
• In Is-A relationship one class is obtaining the features of
another class by using inheritance concept with extends
keywords.
In a IS-A relationship there exists logical memory space.
Class Animal
{
}
public class Mammal extends Animal
{
}
Public class Dog extends Mammal
{
}
Public class Elephant extends Mammal
{
}
IS-A is a way of saying: this object is a type of that object.
Mammal IS-A Animal
Dog IS-A Mammal: Hence Dog IS-A Animal as well.
Elephant IS-A Mammal: Hence Elephant IS-A Animal as well.