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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:38:49+00:00 2026-05-31T04:38:49+00:00

I was wondering how to use a superclass constructor in a subclass but need

  • 0

I was wondering how to use a superclass constructor in a subclass but need to instantiate fewer attributes in the subclass. Below are the two classes. I’m not even sure if I’m doing things right currently. In the second class, there’s an error that says “Implicit super constructor PropertyDB() is undefined. Must explicitly invoke another constructor.” Note that this code is obviously incomplete and there is code that’s commented out.

public abstract class PropertyDB {

private int hectares;

    private String crop;

    private int lotWidth;

    private int lotDepth;

    private int buildingCoverage;

    private int lakeFrontage;

    private int numBedrooms;

    private int listPrice;


    //public abstract int getPricePerArea();
    //public abstract int getPricePerBuildingArea();

    public PropertyDB(int newHectares, String newCrop, int newLotWidth, int newLotDepth, 
            int newBuildingCoverage, int newLakeFrontage, int newNumBedrooms, int newListPrice){
        hectares = newHectares;
        crop = newCrop;
        lotWidth = newLotWidth;
        lotDepth = newLotDepth;
        buildingCoverage = newBuildingCoverage;
        lakeFrontage = newLakeFrontage;
        numBedrooms = newNumBedrooms;
        listPrice = newListPrice;
    }
}


public class FarmedLand extends PropertyDB{


    public FarmedLand(int newHectares, int newListPrice, String newCorn){
        //super(270, 100, "corn");

        hectares = newHectares;
        listPrice = newListPrice;
        corn = newCorn;
    }
}
  • 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-31T04:38:50+00:00Added an answer on May 31, 2026 at 4:38 am

    implicit constructor PropertyDB() exists only if you do not define any other constructors, in which case you will have to explicitly define PropertyDB() constructor.

    The reason you see this error “Implicit super constructor PropertyDB() is undefined. Must explicitly invoke another constructor.” is that in your public FarmedLand(int newHectares, int newListPrice, String newCorn) constructor, super() is automatically called as the first statement, which does not exist in your superclass.

    Here’s a simplified example:

    public class A { }
    

    can be instantiated by using A a = new A() because public A() { } is an implicit constructor of class A.

    public class A {
        public A(int z) { /* do nothing*/ }
    }
    

    can not be instantiated using A a = new A() because by defining an explicit constructor public A(int z) the implicit one is no longer available.

    Moving onto constructors and inheritance, from Java Language Specification section 8.8.7:

    If a constructor body does not begin with an explicit constructor invocation and the constructor being declared is not part of the primordial class Object, then the constructor body is implicitly assumed by the compiler to begin with a superclass constructor invocation “super();”, an invocation of the constructor of its direct superclass that takes no arguments.

    So in your case the first statement executed in public FarmedLand(int newHectares, int newListPrice, String newCorn) constructor is an implicit call to super();, which in your case is not defined implicitly (there’s already a public PropertyDB(int, String, ...) constructor defined) or explicitly (it’s not in the source code)

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

Sidebar

Related Questions

I was wondering how to use cin so that if the user does not
I was just wondering how to use the function :not in my situation. This
Just wondering when you use multiple classes on the one element such as class=foo
I'm currently wondering when to use clean text (not wrapped inside eg. <p> tags)
Strange question, but someone showed me this, I was wondering can you use the
I wondering whether use a webView to create a complex text area done with
Studying compilers course, I am left wondering why use registers at all. It is
I'm wondering how to use a VideoDisplay object (defined in MXML) to display video
I am wondering how to use NUnit correctly. First, I created a separate test
I was wondering why we use the terms push and pop for adding/removing items

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.