Find the errors of the following Java program. Also, correct the following Java code. You cannot reduce
Fantastic news! We've Found the answer you've been seeking!
Question:
Find the errors of the following Java program. Also, correct the following Java code. You cannot reduce the mode of access specifiers. You may add new methods/variables.
classHowToReturn Object{
int a;
HowToReturnObject(int i){a=i;
HowToReturnObjectincrByValue(int i) {
HowToReturnObject temp = new HowToReturnObject(a+i);
returntemp;
}
}
Public class Return Obj {
public staticvoid main(String args[]) {
HowToReturnObject obj1 = new HowToReturnObject(5);
HowToReturnObject obj2 = obj1.incrByValue(3);
System.out.println(obj2.a);
obj2 = obj2incrByValue(15);
System.out.println(obj2.a)
}
Related Book For
Posted Date: