Why Gigster?
    • Top talentTop talent
    • Managed serviceManaged service
    • Liquid workforceLiquid workforce
    • Scalable infrastructureScalable infrastructure
    • Enterprise securityEnterprise security
      Why Gigster?
      • Top talentTop talent
      • Managed serviceManaged service
      • Liquid workforceLiquid workforce
      • Scalable infrastructureScalable infrastructure
      • Enterprise securityEnterprise security

      Java Interview Question

      Use this intermediate question and answer to prepare for your next Java interview.

      Is super class instantiated when subclass is instantiated?


      No, the object created is an instance of both the super class and subclass, but there’s no separate instance of the super class. In order to create a separate instance of the super class it must be instantiated directly.

      The constructor of the super class is always called when the subclass is instantiated, although which constructor of the super class gets called depends on the subclass.

      If nothing is specified explicitly, the default constructor of the super class is called. If there is no default constructor then there is a compile-time error. If any constructor is invoked using super in the subclass, then the default constructor will not be invoked.

      Looking for developers?