Solved

Consider the Following Method

Question 8

Essay

Consider the following method.

public void changeValues(int i, Card c) {
i = 15;
c.setSuit(“Clubs”);
}

Now consider the following snippet of code that calls the method defined above.

int num = 12;
Card fiveOfSpades = new Card(5, “Spades”);

System.out.println(“Before method call:”);
System.out.println(num);
System.out.println(fiveOfSpades.getSuit());

changeValues(num, fiveOfSpades);

System.out.println(“After method call:”);
System.out.println(num);
System.out.println(fiveOfSpades);

What is the output of this code?

Correct Answer:

verifed

Verified

Before method call:
...

View Answer

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions