Question: java: Consider the following definition of class MyClass: class MyClass { private int X; private int Y; public MyClass () { X = 100; Y
java:
Consider the following definition of class MyClass:
class MyClass
{
private int X;
private int Y;
public MyClass ()
{
X = 100;
Y = 200;
}
public MyClass (int A)
{
X = A;
}
public MyClass (int A , int ?)
{
X = A;
Y = B;
}
public void A ()
{
System.out.println (X);
}
public void B ()
{
System.out.println (Y);
}
public int C ()
{
Y = Y + 10;
return Y;
}
public int D ()
{
return X++;
}
}
What is the output of the following code?
public class XYZ {
public static void main(String[] args) {
MyClass K = new MyClass ();
MyClass L = new MyClass (10);
MyClass M = new MyClass (2 , 4);
K.C();
L.D();
M.C();
K.A();
K.B();
L.A();
L.B();
M.A();
M.B();
K.D();
L.C();
M.D();
K.A();
K.B();
L.A();
L.B();
M.A();
M.B();
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
