Question: Given the program with method that receives object. 1. class Add 2. { 3. 4. a) 5. 6. 7. 8. 9. 10. 11. 12.
Given the program with method that receives object. 1. class Add 2. { 3. 4. a) 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. b) int a; int b; Add (int x, int y)// parameterized constructor { a=x; b=x; } void sum (Add anObject) { } int suml=anObject.a+anObject.b; www System.out.println("Sum of a and b:" + suml); class classExAdd { public static void main (String arg[]) { www Add obj =new Add (5,8); obj.sum (obj); wwwwww wwww Refer to Line 8 and Line 9. What are the values of a and b? What is the value of sumi at Line 13? [6 marks] [2.5 marks]
Step by Step Solution
3.41 Rating (151 Votes )
There are 3 Steps involved in it
Answer a The values of a and b at Line 8 and Line 9 respectively are assigned using the constructor ... View full answer
Get step-by-step solutions from verified subject matter experts
