Question: Given the program with method that receives object. 8. 1. class Add 2. { 3. int a; 4. int b; 5. 6 Add (int x,

 Given the program with method that receives object. 8. 1. class

Given the program with method that receives object. 8. 1. class Add 2. { 3. int a; 4. int b; 5. 6 Add (int x, int y) // parameterized constuctor 7. { a=x; 9. b=x; 10. } 11. void sum (Add anobject) 12. { 13. int suml=anobject.a+anobject.b; 14. System.out.println("Sum of a and b: "+suml); 15. } 16. } 17. 18. 19. 20. 21. 22. 23. 24. 25. class classExAdd { public static void main(String arg[]) { Add obj =new Add (5,8); obj.sum (obj); a) Refer to Line 8 and Line 9. What are the values of a and b? [6 marks] b) What is the value of sum1 at Line 13? [2.5 marks)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!