can we access protected member derived class in java code example
Example: java protected
/* similar to private keyword, but also lets both:
- subclasses
- classes in same package
access the variable, method or constructor */
class Superclass {
protected int myNumber = 5;
}
class Subclass extends SuperClass {
// has access to myNumber
}
class InAnotherPackage {
// doesn't have access to myNumber
}