Question: What does the following code display? public class Rental App { public static void main ( String [ ] args ) { Rental r =

What does the following code display?
public class Rental App {
public static void main(String[] args)
{
Rental r = new Rental();
r.setNumOfPersons(5);
r.addPerson();
r.addPerson();
System.out.println(r.getNumOfPersons());
}
}
public class Rental
{
private int numOfPersons;
public int getNumOfPersons()
{
return numOfPersons;
}
public void setNumOfPersons(int numOfPersons)
{
this.numOfPersons = numOfPersons;
}
public void addPerson()
{
numOfPersons = numOfPersons +1;
}
}
Group of answer choices
7
5
0
6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!