1. A class is called House. Write the class declaration 2. For the class House,
ID: 3590777 • Letter: 1
Question
1. A class is called House. Write the class declaration 2. For the class House, write the complete java code of its default constructor 3. In the following code, circle any new variable when it is first declared. Also mark the categories of variables (field, local, parameter) for each. public class Interview Geld private Staff Anterviewe private Personapplicant private int score public void' setinterviewer (staff { this interviewer= s; } public void setApplicant (Person { this.applicant..s; } reld eer public boolean result (inte) boolean found = false ; scoreCi // more code return found; moter public void process (String[n) i intande..0: // more code aca String o Gald ptatic public static string B"Intern":Explanation / Answer
1. Class declaration starts with keyword "class" followed by the <class name>.
2. A default constructor is like a method signature but it has the same name as class and no arguments and no return type.
3. A new field declared when it specify its data type;
list of new variable declaration along with their types(field/local/parameter)
interviewer field type (means class variable)
applicant field type
score field type
s parameter type (means declared in the method signature)
c parameter type
n parameter type
found local type (means variable declared inside the method body)
index local type
4. Four fields (interviewer, applicant, score JOB) and one static field (JOB).
5. Four methods are defined. result method is a public method means it can be accessible to anyone. It has one argument type int. It has boolean type return.
6.
7. c because in c option using "this" keyword we are assigning the value of method argments to current object fields which is right on constructor declaration.
8. getter method is used for geting the value of field of a class and setter method is used for changing or assigning the value to field of class.
public String getPlayer()
{
return this.player;
}
public void setPlayer(Sting p)
{
this.player=p;
}
public int getBet()
{
return this.bet;
}
public void setBet(int b)
{
this.bet=b;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.