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 9013139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:11:07+00:00 2026-06-16T03:11:07+00:00

This question has been bugging me for a while now, and I haven’t found

  • 0

This question has been bugging me for a while now, and I haven’t found a good answer (other than “that’s just how it is”).

Let me give some background code, to show what I’m talking about.

class Note {
    private final String name = "Note";

    public Note() {
        System.out.println(name);
    }
    // ...
}

class Todo extends Note {
    private final String name = "Todo";

    public Todo() {
        System.out.println(name);
    }
    // ...
}

// ...
Note note = new Todo(); // case 1
Todo todo = new Todo(); // case 2

So how come both case 1 and case 2 print out:

Note
Todo

This makes no sense, since Todo() (constructor) does not call super() (at least not visibly). Why would the sub-class have to call the parents default constructor, why not just require any sub-class to implement a constructor?

I read a couple questions related to this, but none answer why.

Edit:
I guess my example was kind of poor, but It’s actually a derivative from a Java 7 Certification question.. From the collective of answers I now understand why. Let me provide a better example:

public Note {
    private String description;

    public Note() {
        description = "I'm a Note";
    }

    public Note( String description ) {
        this.description = description;
    }

    // getters/setters/etc.
}

public Todo extends Note {
    // field vars..

    public Todo() {
        // empty constructor
    }

    // getters/setters/etc..
}

So now this makes more sense, since when Todo is created, if super() was not inserted behind the covers, the Note aspect of the Todo would not be initialized. Which would be pointless to have a sub-class in that case. Thanks all!

  • 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-16T03:11:08+00:00Added an answer on June 16, 2026 at 3:11 am

    The question can be separated into two parts.

    1. Why does any constructor of the superclass have to be called? This is easy: the constructor is responsible for setting up the state of the object, and since there can be state in the superclass not visible to the subclass code (i.e. private fields), this can only be dealt with by calling a constructor of the superclass.
    2. Why don’t you have to call super() explicitly? This is just a fairly arbitrary design decision made in Java to make code look simpler. It ties in nicely with the concept of a default constructor (i.e. the implied no-arg constructor that exists in classes that don’t have an explicit constructor defined), although as can be seen in your example, it also works when you have a no-arg constructor explicitly defined in the superclass.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a question that has been bugging me for a while. I started
I have a question that has been bugging me for a while now. I
This is a question that has been bugging me for a while and I
I've got a question that has been bugging me for a while now, but
This question has been bugging me for a while now. When writing a CSS
This question has been bugging me for a long time now but essentially I'm
This is a question that's been bugging me for some time now: In photoshop/GIMP,
This question has been asked in various permutations, but I haven't found the right
This question has been asked several times in various forms but I haven't found
This question has been bugging me for a while: I've read in MSDN's DirectX

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.