Scenario:two classes (super class and subclass) in different packages.
Super class has two protected methods,static and nonstatic method.
Subclass using reference on superclass can "see" protected static method but cannot see non static protected method...
Static members are not inherited and
does it mean that using protected with static members is similar to using public??
It is indeed true that static methods are not polymorphic, and you can't override them and get polymorphic behavior. But static methods are inherited in the sense that they're available amongst the child class's methods; you can call a static method using the child class's name, or using an instance of the child class, or without qualification in the body of a child class.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Indeed, a subclass has access to all the static methods of the parents. Static methods are methods of the class and since a subclass is that class it has access. Outsider classes can use static methods as utility methods if they are public.
An outsider class needs public access to the static methods.
So conclusion would be:ChildInDifferentPackage can acess parent's public and protected static methods.
And child also gets those methods through inheritance...
And child does not see parent's private and default static methods nor gets them through inheritance.
I guess everyone has an angle. Fine, what do you want? Just know that you cannot have this tiny ad: