class a extends b
{
}
class b extends a
{
}

why java doesn't support cyclic pls explain me with example

Answers were Sorted based on User's Feedback



class a extends b { } class b extends a { } why java doesn't support cyclic pls explain..

Answer / lakshminarayana

IN THE FIRST BLOCK CLASS IS EXTENDING CLASS B.HERE A IS SUB
CLASS OF CLASS B.
AGAIN CLASS B IS EXTENDING CLASS A WHICH IS A SUB CLASS OF
B.A SUB CLASS NEVER BECOME A SUPER CLASS FROM WHICH IT IS
EXTENDED. SO IN JAVA IT THROWS A EXCEPTIONS LIKE CYCLIC
INHERITANCE NOT POSSIBLE...



... I THINK IT WILL HELPFUL FOR U.

Is This Answer Correct ?    30 Yes 2 No

class a extends b { } class b extends a { } why java doesn't support cyclic pls explain..

Answer / kaustav chatterjee

Every class in java by default extends the Object class and they have to cause java is almost an object oriented language.but if we take this scenario where class B extends class A and class A extends class B then as java don't support multiple inheritance or multiple super class then class A cannot extend the Object class and cannot be a Object type or subclass of Object class but by definition of JAVA every class is a subclass of Object class.Hence it's not supported by JAVA as it contradicts basic definition of JAVA.

but if we don't extending any class in class A then it by default extends Object class and class B by extending class A also extending Object class.so there is no problem.

Is This Answer Correct ?    0 Yes 0 No

class a extends b { } class b extends a { } why java doesn't support cyclic pls explain..

Answer / anandhi

java is nt support multiple inheritance... so we have go to
nxt level interface program... we will use interface
concept then this pgm possible

Is This Answer Correct ?    1 Yes 17 No

Post New Answer

More Core Java Interview Questions

What is variable and constant explain with example?

0 Answers  


how to create a jar file in java

1 Answers  


what is use of session tracking ?with example?

1 Answers   Photon,


Which method must be implemented by all threads?

0 Answers  


Can you run java program without main method?

0 Answers  


What are checked exceptions?

0 Answers  


To what value is a variable of the Boolean type automatically initialized?

3 Answers  


Are arrays static in java?

0 Answers  


What is the function of java?

0 Answers  


How to change the priority of thread or how to set the priority of thread?

0 Answers  


Read data from console and print in one file. That would be in C:\temp ? Thanks, Bose

3 Answers   Oracle, Surya Software,


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

9 Answers   BearingPoint, TCS,


Categories