public class YClass private int a private int b public void
public class YClass{
private int a;
private int b;
public void one()
{...}
public void two(int x, int y)
{...}
public YClass()
{...}
}
public class Xclass extent Yclass
{
private int z;
public void one()
{...}
public XClass()
{....}
A.write the definition of the default constructor of Ylass so that the instance variable of YClass are initialized to 0.
B.write the definition of the default constructor of Xclass so that the instance variable of XClass are initialized to 0.
C.Write the definition of the method two of YClass so that the instance variable a is initialized to the value of the first parameter of two, and the instance variable b is initialized to the value of the second parameter of two.
Solution
public class YClass
{
private int a;
private int b;
public void one()
{...}
// instance variable a is initialized to the value of the first
// parameter of two, and the instance variable b is initialized
// to the value of the second parameter of two.
public void two(int x, int y)
{
a = x;
b = y;
}
public YClass()
{
// instance variable of YClass are initialized to 0.
a = 0;
b = 0;
}
}
public class Xclass extent Yclass
{
private int z;
public void one()
{...}
public XClass()
{
//instance variable of XClass are initialized to 0.
z = 0;
}
}

