Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Why java Don't Support Multiple interitence

Answer Posted / midhula kadiyala

If you extend more than one class JVM does n't understand
for which object it has to create object first.so ambiguios
occurs.That's y java does n't support multiple inheritance.


We can implement multiple inheritance by using interfaces.

Interface A
{
public void X();
}
class B implements A
{

public void X()
{
s.o.p("this is function x");
}
public void Y()
{
s.o.p("this is function y");
}

}

class C extends B
{
public void X(){...}
public void j(){...}

P S V M()
{

A a =new C();
a.X();
}
}

if a class wants to extend 1 or more classes define those
function definitions in one interface and in another class
provide bodies by implementing those interface.

if the class can extend the class which is implementing that
interface then u can access all functions present in that
interface.


here my interface A

i provide bodies in class B by implementing interface A

class C extend that class B

and class c is able to access all the methods present in the
interface by creating the reference of an interface with the
object of class C

(remember 1 thing to the reference of interface we can
assign object of class only if it is implementing that
interface)

here class c extends class B and again class B implements

interface A

so i can write

A a= new C();

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a stack class in java ?

1063


What is static block?

1076


What is JFC?

1177


What is the properties class?

1040


What is abstract class? Explain

997


Explain about field hiding in java?

892


What is your platform?s default character encoding and how to know this?

2337


What is character in data type?

929


Is list thread safe in java?

886


Addition to previous section relative word 5th one was Putrid ans: rotten, also there was prob. in 1st section on bucket weight ans:10kg, also there was a prob. on train speed to find bridge length ans:800 mtrs.

2131


How many decimal digits is 64 bit?

889


What is the difference between a local variable and an instance variable?

1040


State some situations where exceptions may arise in java?

1008


What is method in java with example?

913


What do you mean by Hash Map and Hash Table?

1041