adspace


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

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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an object in java and how is it created?

1141


What is parsing in java?

1044


What is the difference between break and continue statements?

1128


Differentiate between static and non-static methods in java.

1129


How to create a base64 decoder in java8?

1139


explain different ways of using thread? : Java thread

1084


What do you mean by an interface in java?

1105


Realized?

2266


What are the differences between heap and stack memory in java?

1143


Write a program to print count of empty strings in java 8?

1087


Explain public static void main(string args[]) in java.

1079


Is minecraft 1.15 out?

1046


What is a classloader in java?

1091


How to sort array in descending order in java?

997


Write a program to find the whether a number is an Armstrong number or not?

1101