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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:00:30+00:00 2026-06-13T20:00:30+00:00

Class A: public class A { private String firstName; public String getFirstName() { return

  • 0

Class A:

public class A {    

    private String firstName;

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

Class B:

public class B extends A{

    private int billNum;

    B(String firstName, String billNum) {
        super(firstName);
        setBillNum(billNum);

    }

    public int getBillNumr() {
        return billNum;
    }

    public void setBillNum(int billNum) {
        this.billNum = billNum;
    }

1.) Now i want to add a default like constructor like B() {}, but i am not allowed to do so. Why is this ?

  • 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-13T20:00:31+00:00Added an answer on June 13, 2026 at 8:00 pm

    In the subclass constructor you call a one-argument superclass constructor, which you didn’t declare. Add A(String firstName) { this.firstName = firstName; } to the superclass. Alternatively, replace the line super(firstName); with setFirstName(firstName); in the constructor of B.

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

Sidebar

Related Questions

Consider this simple example - public class Person { private String name; private Date
Let's say I have a class like this: public class Person { private String
@Entity public class Blobx { private String name; private BlobKey blobKey; @Id @GeneratedValue(strategy =
I have the following beans: public class CodedEntity { private String name; private String
I have a OneToMany relationship: public class Class1{ private String attr1; private String attr2;
My Address Class: public class Address implements java.io.Serializable { private String addressId; private String
I have the following abstract class: public abstract class AbstractGroup { private String name;
Say I create some object class like so public class thing { private String
I wrote two methods to check there performance public class Test1 { private String
I have the following WCF DataContract: [DataContract] public class Occupant { private string _Name;

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.