“every class in java extends the MetaClass Object” does it imply that every subclass causes a Diamond issue

后端 未结 3 553
鱼传尺愫
鱼传尺愫 2020-12-18 16:23

These two facts in java

Fact 1

Every class in java by default extends the java meta class Object

and

Fact

3条回答
  •  一整个雨季
    2020-12-18 16:33

    Yes, both the statements are correct.

    It’s true that every class in java extends the meta class Object.

    Still ClassB doesn’t have multiple inheritance because at compile time java shifts the Object Class by one level.

    enter image description here

    This way now ClassA now extends Object and not ClassB.

    This way ClassB is not having multiple inheritance so fact2 is followed.

    Now ClassB extends ClassA and ClassA extends Object thus through MultiLEVEL Inheritance ClassB extends Object; fact1 followed

提交回复
热议问题