Consider the following two class code:
Public class MyClass {
Protected int data1 = 0;
Private char data2 = 0;
Public MyClass(int x) {
Data1= x;
Data2 = data1 + 1;
}
Public getData2() {
Return data2;
}
Public void doWork() {
System.out.println(“In doWork of MyClass”);
}
}
Public class YourClass extends MyClass {
Private int data3 = 0;
Public YourClass(int x) {
Super(x);
Data3 = x + 2;
}
Public void doWork() {
System.out.println(“In doWork of YourClass”);
}
}
Suppose we have the following code:
MyClass m;
YourClass y;
M = MyClass(1);
Y = YourClass(2);
M.doWork();
Y.doWork();
M = y;
M.doWork();
I) (5 points) Show the all the class attribute values of the two objects (m and y), after the objects get instantiated (be careful).
ii) (5 points) What gets printed when the code snippet is executed.