Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Person { //Data members private String FirstName; private String LastName; private int Age; private String Gender; private String City; //default constructor public Person()

public class Person {

//Data members

private String FirstName;

private String LastName;

private int Age;

private String Gender;

private String City;

//default constructor

public Person()

{

this.FirstName = "Unknown";

this.LastName = "Unknown";

this.Age = 0;

this.Gender = "Unknown";

this.City = "Unknown";

}

//non default constructor

public Person(String FN, String LN, int Age, String GN, String City)

{

this.FirstName = FN;

this.LastName = LN;

this.Gender = GN;

this.City = City;

if (Age < 0)

this.Age = 0;

else

this.Age = Age;

}

//set methods

public void setFirstName(String FN)

{

this.FirstName = FN;

}

public void setLastName(String LN)

{

this.LastName = LN;

}

public void setAge(int Age)

{

if (Age < 0)

this.Age = 0;

else

this.Age = Age;

}

public void setGender(String GN)

{

this.Gender = GN;

}

public void setCity(String City)

{

this.City = City;

}

//get methods

public String getFirstName()

{

return this.FirstName;

}

public String getLastName()

{

return this.LastName;

}

public int getAge()

{

return this.Age;

}

public String getGender()

{

return this.Gender;

}

public String getCity()

{

return this.City;

}

//toString method

public String toString()

{

String Print;

Print = " Fist Name: " + this.getFirstName() + " Last Name: " +

this.getLastName() + " Age: " + this.getAge() + " Gender: " + this.getGender() +

" City: " + this.getCity();

return Print;

}

}

  1. How many constructors this class can have?
  2. How many getters and setters this class can have?
  3. What a toString() method will display in this class?

Open Eclipse, and develop this class on the basis of information you have written in answers above.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions

Question

1. What is Ebola ? 2.Heart is a muscle? 3. Artificial lighting?

Answered: 1 week ago

Question

=+How should it be delivered?

Answered: 1 week ago