Object Oriented Programming (OOPs)
© examsiri.com
Question : 58 of 72
Marks:
+1,
-0
Click the Exhibit button.
Which statement, placed at line 10, causes the code to print “Thevalue of p is 420.”?
1. class Payload {
2. private int weight;
3. public Payload(int wt) { weight = wt; }
4. public void setWeight(mt w) { weight = w; }
5. public String toString { return Integer.toString(weight); }
6. }
7.
8. public class TestPayload {
9. static void changePayload(Payload p) {
10. /* insert code here */
11. }
12.
13. public static void main(String[] args) {
14. Payload p = new Payload();
15. p.setWeight(1024);
16. changePayload(p);
17. System.out.println(”The value of p is “+ p);
18. }
19. } Which statement, placed at line 10, causes the code to print “Thevalue of p is 420.”?
Go to Question: