What does the following code display? public class RentalApp…
What does the following code display? public class RentalApp { public static void main(String[] args) { Rental r = new Rental(); r.setPersonCount(5); r.addPerson(); System.out.println(r.getPersonCount()); } } class Rental { private int personCount; public int getPersonCount() { return personCount; } public void setPersonCount(int numOfPersons) { this.personCount = numOfPersons; } public void addPerson() { personCount++; } }
Read DetailsAssuming that the following two methods are written inside a…
Assuming that the following two methods are written inside a class named test, what is the output of the following code? public static void main(String[] args) { int a = 5; int b = 9; callMethod(a,b); System.out.println(“a = “+a+”\nb = “+b); } public static void callMethod(int a, int b) { a = a + 1; b = b + 5; System.out.println(“a = “+a+”\nb = “+b); }
Read Details