I have modified the Thief class by making it extends the Cop class. now since Thief is a subclass of the Cop class, eventhough the fire method in the Cop class is protected. there should not be compile time error.
package crime;
import justice.*;
class Thief extends Cop{
public static void main(String args[]){
Cop obj = new Cop();
obj.fire(); //Compile Time Error
}
}
Thief.java:7: error: fire() has protected access in Cop
obj.fire(); //Compile Time Error
^
1 error
Why i am getting this error.??
Course: Learn Object-Oriented Programming in Java - Learn Interactively
Lesson: Access Modifiers - Learn Object-Oriented Programming in Java