Hi all
This question is 58 from
ExamLab's 2nd exam.
clasA.java
--------------
package pkga;
public class clasA{
protected void doThis(){}
}
===================================
clasB.java
----------------
package pkgb;
import pkga.clasA;
public class clasB extends clasA{
public static void main(
String args[]){
/* Insert Here */
ca.doThis();
}
}
Correct answers mentioned are ClasB ca = new ClasB(); and ClasB ca = new ClasB(){protected void doThis(){}};
I didnt get the point that how to call a protected method using its instance in a different package? Second answer looks correct but not the first one. Can any one explain please?