answersLogoWhite

0


Best Answer

In database design, object-oriented programming, and knowledge representation, we often describe the relationship between two things as either "is-a" or "has-a" (but not both).

For example,

An avocado "is-a" fruit. (An avocado is a specific kind of fruit. A fruit is a generalization of things like an avocado. An avocado has all the things and characteristics that all fruit have -- an outer skin, an edible flesh, grows on plants, etc.)

An avocado "has-a" seed. (An avocado contains a seed. The seed is one of several parts of an avocado.)

(Many people find this "is-a" term more understandable than the terms "meronym" and "hyponym").

When writing computer programs, confusing these two kinds of relationships is a common source of bugs.

The "is-a" relationship is often represented in a program using "class inheritance", subclasses (and superclasses).

The "has-a" relationship is often represented in a program using a class variable.

The class variable is typically a basic type for exclusive things, such as "birthday".

The class variable is typically a reference to a class as a class variable for shared items, such as "mother".

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

is-a relation ship with inheritance like apple is a fruit and has-a relationship with its object like apple has a seed

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between is-a relationship and has-a relationship in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is difference between java 2 and java 5?

They are different versions. Java 5 is newer than Java 2. Think of it like the difference between the Playstation 1 and the Playstation 3.


Major difference between c and java?

Java is object oriented, C is not...


What is the difference between connectivity in java?

kamina


What is difference between connectivity in java?

kamina


What is the main difference between UNIX and JAVA?

Unix is an operating system, Java is a language.


Difference between recordset and resultset in java?

Rowset


What is the difference between JAD and JAR?

JAD-Java Application Description JAR-Java archive


What is the difference between java and object oriented programming?

java is a programming language/platform that embodies object oriented programming concepts. The question of what is the difference is like asking what is the difference between cars and a Volvo.


What is the difference between c plus plus and java programming?

Java doesn't have pointers. C++ has pointers.


What difference between InputStreamReader and DatainputStream in java?

Both are same


WAP to show the difference between a variable and static variable?

difference between constant and static variables in java


What is the difference between Windows and Java?

Windows is an operating system whereas Java is a programming language. They are entirely different.