Question: Given: 1 class TestObj{ 2 int x; 3 TestObj updateObject(){ 4 ________(X)_________ 5 x=900; 6 return obj; 7 } 8 int receiveObject(TestObj obj){ 9 x=100;
Given:
1 class TestObj{
2 int x;
3 TestObj updateObject(){
4 ________(X)_________
5 x=900;
6 return obj;
7 }
8 int receiveObject(TestObj obj){
9 x=100;
10 return x;
11 }
12 public String toString(){
13 return "Answer=" + x ;
14 }
15}
16 class TestRetObject {
17 public static void main(String[] args) {
18 TestObj obj= new TestObj();
19 obj.updateObject();
20 System.out.println(obj);
21 obj.receiveObject(obj);
22 System.out.println(obj);
23 }
(a) Which line number shows calling a method bypassing an object?
(b) Which line number shows calling a method that returns an object?
(c) Write a statement in (X) to complete method updateObject().
(d) What will be printed by line 20 and 22 if toString() method line 12-14 are commented?
oop java
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
