Hello,
Please tell me in Java we don't have a multiple inheritance? so,in which function we use these inheritance.

Thanks

Recommended Answers

All 5 Replies

Hello,
Please tell me in Java we don't have a multiple inheritance? so,in which function we use these inheritance.

Thanks

You say:
> we don't have a multiple inheritance
but then you ask:>in which function we use these inheritance

The only thing I can say is that java doesn't have multiple class inheritance, but multiple Interface implementation.

If that doesn't cover you, ask a better question

What do you mean?

There isn't multiple inheritance in Java. It's a single inheritance only language. :)

What do you mean?

There isn't multiple inheritance in Java. It's a single inheritance only language. :)

That's what javaAddict said, Java does not have multiple class inheritance, you can only only extend (is-A) one class. However you can implement (has-A) any amount of interfaces you want.

Hello,
Please tell me in Java we don't have a multiple inheritance? so,in which function we use these inheritance.

Thanks

c there is no concept of multiple inheritance in java but some time it seems that there may be a multiple inheritence....

That's what javaAddict said, Java does not have multiple class inheritance, you can only only extend (is-A) one class. However you can implement (has-A) any amount of interfaces you want.

Hi Sriran1 ,

what jasimp said is correct expect that implementing a interface is *NOT* mean "Has-A" relationship.

Has-A relationship is what when an Class has other Class's object in it's attribute

Implementing a interface is also means "Is-A" relationship

e.g

//for Is-A 
class Mammal {
}

class Dog extends Mammal { }

//for Has-A 

class Tail { }

class Dog extends Mammal { // Dog IS-A mammal
  Tail tail ;     //  and Has-A Tail
 }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.