How many objects are created due to inheritance in java?

前端 未结 14 1633
长情又很酷
长情又很酷 2020-11-29 18:48

Let\'s say I have three classes:

class A {
    A() {
        // super(); 
        System.out.println(\"class A\");
    }
}
class B extends A {
    B() {
             


        
14条回答
  •  粉色の甜心
    2020-11-29 19:43

    1. There will be one and only one object will be created and ie. A object.

    2. You can imagine like when class A extends B, then all methods and variables are copied to class A.

提交回复
热议问题