Question: What is displayed by the following code segment? public class XYZ { private int a; public X Y Z ( ) { a = 5

What is displayed by the following code segment?
public class XYZ {
private int a;
public XYZ(){a=5;}
public XYZ(int arg1){a=arg1;}
public int getVal(){return a; }
public void updateVal(int arg1){a+=arg1;}
public static void main(String[] args){
XYZ obj1= new XYZ();
XYZ obj2= new XYZ(3);
obj1. updateVal(obj2.getVal());
System.out.println(obj1.getVal());
}
//rest of file not shown...
Select one
A.3
B.5
c.6
D.8
E.10
 What is displayed by the following code segment? public class XYZ

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!