Solved

Consider the Following Method

Question 22

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

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents