-3

Suppose if a class A is superclass of sub class B and class B is a superclass for sub class C then which of the following statements should be used? And tell whether the statement not chosen is 'wrong' or is there any other reason?

Statement 1: sub class C has two/multiple superclasses 'A' and 'B'

Statement 2: sub class 'C' has only one superclass 'B'

Community
  • 1
  • 1
Himanshu Roy
  • 43
  • 2
  • 11
  • By the way, Java does not support multiple inheritance, then there would be only one Superclass for any subclass. For example, Object class is a superclass for all Classes in java when a class does not extend any other class – Pandey Amit Oct 04 '18 at 21:12
  • 'Object' is a super class of a class that doesn't explicitly have an 'extends' clause, so if statement 2 is wrong, then statement 1 is wrong as well because it doesn't include 'Object'. – Roddy of the Frozen Peas Oct 04 '18 at 21:16

2 Answers2

3

I would say statement 2 is more accurate.

Essentially B has access to all the protected/public fields/methods of A and C has access to all the protected/public fields/methods of A and B

0

I would say statement 1 is true and statement 2 is false.

I don't have explicit docs... but if you look at

https://docs.oracle.com/javase/tutorial/java/IandI/objectclass.html

If a class, or one of its superclasses, implements the Cloneable interface

I take this to mean there could be multiple superclasses and in java the only way for that to happen is if there is an inheritance chain and all classes in the chain above you are considered super classes.

Charles
  • 944
  • 5
  • 9