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

The Archive Base Latest Questions

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

When compiling this program, I get error- class Person { Person(int a) { }

  • 0

When compiling this program, I get error-

 class Person {
    Person(int a) { }
 }
 class Employee extends Person {
    Employee(int b) { }
 }
 public class A1{
    public static void main(String[] args){ }
 }

Error- Cannot find Constructor Person().
Why defining Person() is necessary?

  • 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-31T05:11:50+00:00Added an answer on May 31, 2026 at 5:11 am

    When creating an Employee you’re creating a Person at the same time. To make sure the Person is properly constructed, the compiler adds an implicit call to super() in the Employee constructor:

     class Employee extends Person {
         Employee(int id) {
             super();          // implicitly added by the compiler.
         }
     }
    

    Since Person does not have a no-argument constructor this fails.

    You solve it by either

    • adding an explicit call to super, like this:

       class Employee extends Person {
           Employee(int id) {
               super(id);
           }
       }
      
    • or by adding a no-arg constructor to Person:

      class Person {
          Person() {
          }
      
          Person(int a) {
          }
      }
      

    Usually a no-arg constructor is also implicitly added by the compiler. As Binyamin Sharet points out in the comments however, this is only the case if no constructor is specified at all. In your case, you have specified a Person constructor, thus no implicit constructor is created.

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

Sidebar

Related Questions

import java.io.*; public class ArrayApp{ public static void main(String[] args){ System.out.println(lllll); } // end
Consider the following C program, 'pause.c': void main() { pause(); } Compiling this on
I have a confusion related to this program. #include <stdio.h> int main(void) { int
Recently I tried compiling program something like this with GCC: int f(int i){ if(i<0){
I get an undefined reference to 'typeof'-error compiling and linking this: #include <stdio.h> #include
I get this error when compiling a C# application. Looks like a trivial error,
Consider a simple program in C++: #include <iostream> class link {}; int main() {
While compiling a program in Java I got this big WARNING warning: [unchecked] unchecked
I'm have horrendous problems trying to get a JOGL program compiling using Netbeans 6.9.
I get this warning when compiling my code in VS2008 warning C4275: non dll-interface

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.