Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8964343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:33:59+00:00 2026-06-15T16:33:59+00:00

class A { A() { System.out.print(A); } } class B extends A { B()

  • 0
class A {

    A() {
        System.out.print("A");
    }
}

class B extends A {
     B() {
        System.out.print("B");
    }
}

class C extends B {
 C() {
        System.out.print("C");
    }
}

public class My extends C {
My(){
super();
}
    public static void main(String[] args) {
        My m = new My();
    }
}

Question starts from one Interview Question (what happens when an object is created in Java?)

and answer is…

The constructor for the most derived class is invoked. The first
thing a constructor does is call the consctructor for its
superclasses
. This process continues until the constrcutor for
java.lang.Object is called, as java.lang.Object is the base class for
all objects in java. Before the body of the constructor is executed,
all instance variable initializers and initialization blocks are
executed. Then the body of the constructor is executed. Thus, the
constructor for the base class completes first and constructor for the
most derived class completes last.

So, according to above statement, answer should be ABCC, but it showing only ABC. Although, when i’m commenting the super() in derived constructor. Then, output is ABC. Please, help me to figure out, did i misunderstand the above paragraph. ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:34:00+00:00Added an answer on June 15, 2026 at 4:34 pm

    No, the answer is ABC

    My m = new My(); 
    

    The above first invokes My class, then a super call is made to its super class i.e., C class, then a super call to B class is made, then a super call to A Class, then a Super call to java.lang.Object as all objects extend java.lang.Object.

    Thus the answer is ABC.

    You don’t really need to explicitly call super() in your My class as it’d be included by the compiler unless you call an overloaded constructor of that class like this(something).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

import java.lang.Math; public class NewtonIteration { public static void main(String[] args) { System.out.print(rootNofX(2,9)); }
public class Foo { public static void main(String[] args) { float f; System.out.println(f); }
class A { public static void main(String[] args) { A a = new A();
class a{ public void foo(int a){ System.out.println(super); } } class b extends a{ public
public class Test extends Thread{ public void hello(String s){ System.out.println(s); } public void run(){
class Patmatch { static String strLine=; public static void main(String [] args) { try
class C{ static int f1(int i) { System.out.print(i + ,); return 0; } public
package main; class F { void f() { System.out.print(F.f() ); this.g(); } void g()
class A { void F() { System.out.println(a); }} class B extends A { void
public class Animal { public void eat() { System.out.println("I eat like a generic Animal.");

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.