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

  • Home
  • SEARCH
  • 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 7074603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:04:40+00:00 2026-05-28T06:04:40+00:00

Possible Duplicate: Why does this() and super() have to be the first statement in

  • 0

Possible Duplicate:
Why does this() and super() have to be the first statement in a constructor?

I just learned that at school, but the teacher doesn’t know why.

I can think of some good reasons, but I think there are cases when the initializing can be done later in the constructor- before you use the variables form the mother class, for example. OK, the variables should be initialized from the start, but that’s not always necessary.

I”m guessing there are a more reasons for that why must super() be placed in the first line of the constructor.

So, why must I write super() in the first line of the constructor, when I’m inheriting a class?

  • 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-05-28T06:04:40+00:00Added an answer on May 28, 2026 at 6:04 am

    The class you’re inheriting from needs to be able to complete its construction, before you have start working on your own class.

    Without doing this you could do lots of "bad" things, e.g.

    1. Pass this to another method somewhere else, which uses the base class, before its constructor has run. That would break lots of assumptions

    2. Call polymorphic functions that haven’t been "set up" correctly yet. As well as anything done by the class itself the implementation possibly uses the constructor call to handle implementation internals too.

      Accessing an object before it’s been constructed is bad, in the same way that fried chicken "is-a" chicken you really don’t want to access (eat) that chicken before it’s been fried.

    3. Access protected/public member variables of the base class which the base class was trying to promise would always be initialised to some state.

    It’s perfectly reasonable for a class to make a promise that any instances of it will always be in some given state. If you get a chance to do things before the constructor has been called then there’s no way to honour promises like that. Essentially the "is-a" relationship wouldn’t actually hold if the thing that it "is" isn’t actually that thing yet!

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

Sidebar

Related Questions

Possible Duplicate: Why does this Random Number Generator not random? I have this test
Possible Duplicate: Got Hacked - Anyone know what this PHP Code Does? I just
Possible Duplicate: What does this mean? (function (x,y)){…}){a,b); in JavaScript I have the following
Possible Duplicate: What does this construct mean? I'm encountering this syntax for the first
Possible Duplicate: Does a exception with just a raise have any use? Is there
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Possible Duplicate: Where does ‘Hello world’ come from? What was the first Hello World
Possible Duplicate: How does this bash fork bomb work? Today one of my friend
Possible Duplicate: How does this work? Weird Towers of Hanoi Solution While surfing Google,
Possible Duplicate: What does this C++ code mean? I'm trying to map a C

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.