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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:28:26+00:00 2026-06-11T05:28:26+00:00

OK, i need someone to explain to me where to start on this project.

  • 0

OK, i need someone to explain to me where to start on this project.

First I need to overload the constructor by adding a default (no-args) constructor to Person that defines an object to have the name “N/A” and an id of -1.

Then i need to add a setter method named reset that can be used to reset the two private instance variables of this class to two values passed in as parameters.

Then I need to add a getter method named getName and getId that can be used to retrieve these two private variables

Here is the code:

public class Person
{
private String name;
private int    id;
private static int personCount = 0;

// constructor
public Person(String pname)
{
name = pname;
personCount++;
id = 100 + personCount;
}



public String  toString()
{
 return "name: " + name + "  id: " + id
  + "  (Person count: " + personCount + ")";
}

// static/class method
public static int getCount()
{
  return personCount;
}

////////////////////////////////////////////////

public class StaticTest
{
  public static void main(String args[])
{
    Person tom = new Person("Tom Jones");
    System.out.println("Person.getCount(): " + Person.getCount());
    System.out.println(tom);
    System.out.println();

    Person sue = new Person("Susan Top");
    System.out.println("Person.getCount(): " + Person.getCount());
    System.out.println(sue);
    System.out.println("sue.getCount(): " + sue.getCount());
    System.out.println();

    Person fred = new Person("Fred Shoe");
    System.out.println("Person.getCount(): " + Person.getCount());
    System.out.println(fred);
    System.out.println();

    System.out.println("tom.getCount(): " + tom.getCount());
    System.out.println("sue.getCount(): " + sue.getCount());
    System.out.println("fred.getCount(): " + fred.getCount());
}
}

I’m not exactly sure where to start and I don’t want just the answer. I’m looking for someone to explain this clearly.

  • 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-11T05:28:27+00:00Added an answer on June 11, 2026 at 5:28 am

    First I need to overload the constructor by adding a default (no-args) constructor to Person that defines an object to have the name “N/A” and an id of -1.

    Read about constructors here.

    The Person class already contains a ctor that takes 1 argument. What you need to do is create a “default ctor” which is typically a ctor w/out any parameters.

    Example:

    class x
    {
       // ctor w/ parameter
       //
       x(int a)
       {
          // logic here
       }
    
       // default ctor (contains no parameter)
       //
       x()
       {
         // logic here
       }
    }
    

    Then i need to add a setter method named reset that can be used to reset the two private instance variables of this class to two values passed in as parameters.

    Setter methods are used to “encapsulate” member variables by “setting” their value via public function. See here.

    Example:

    class x
    {
       private int _number;
    
       // Setter, used to set the value of '_number'
       //
       public void setNumber(int value)
       {
         _number = value; 
       }
    }
    

    Then I need to add a getter method named getName and getId that can be used to retrieve these two private variables

    Getters do the opposite. Instead of “setting” the value of a private member variable, they are used to “get” the value from the member variable.

    Example:

    class x
    {
       private int _number;
    
       // Getter, used to return the value of _number
       //
       public int getNumber()
       {
          return _number;
       }
    }
    

    Hope this helps

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

Sidebar

Related Questions

Can someone help me out please...I'm trying to start my first programming project. It
I need someone to explain the following names; Asynchronous Delegates. Asynchronous methods. Asynchronous events.
Can someone please explain me why would a UDP Server not need to use
I don't understand the need for self-joins. Can someone please explain them to me?
Please i need someone to help convert this query entity(c#) form. select * from
Sorry fot his newbie question. But I really need a start on this one.
Can someone explain why this code halts at startFileHTTP()? The jetty server starts but
I don't know how to explain this properly, someone please edit my title and
Can someone explain this behavior in Generics? I have a generic function in C#
I need someone help. When I open https://developers.facebook.com/docs/reference/api/ and clicked https://graph.facebook.com/me/likes?access_token=blablabla , I got

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.