Can a class be a super class and a sub-class at the same time? Give example.

Answer Posted / hrindows@gmail.com

If there is a hierarchy of inheritance used, a class can be a super class for another class and a sub-class for another one at the same time.
In the example below, continent class is sub-class of world class and it’s super class of country class.
public class world {
..........
}
public class continenet extends world {
............
}
public class country extends continent {
......................
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why constructor has no return type?

869


Which are the two subclasses under exception class?

772


Why we go for collections in java?

780


What are the differences between this and super keyword?

764


Is string a class in java?

749


What does sprintf mean?

744


What is ternary operator?

775


What is consumer interface?

778


Is main a keyword in java?

765


How will you calculate the depth of a binary tree if the tree contains 15 nodes?

862


What are keywords give examples?

825


Can an anonymous class be declared as implementing an interface and extending a class in java programming?

920


how many types of Inheritance?

945


Difference between a process and a program?

843


Difference between final and effectively final ?

856