a) instantiate an object of an abstract class, it is only possible to access its attributes defined as public.
Can not instantiate an abstract class
b) defining an attribute as static in a class, you can only access it after there is at least one instantiated object of that class.
A static attribute belongs to the class and not to the instance, so it can be accessed at any time, even without instances of this class.
c) declare an abstract method in a class, all classes inheriting from that class to instantiate objects are required to implement this method.
Exactly, an abstract method has no implementation, so it can not be instantiated. Classes that inherit from it need to implement it, otherwise the inherited class needs to be abstract as well, which will prevent it from being instantiated.
d) define a method with the final modifier, in a child class, in a base class of a class hierarchy, this method can only be overwritten with public visibility.
final
indicates that the method will not overlap, so the rest of the statement is incorrect.
e) define a method with protected visibility, in a child class, in a base class of a class hierarchy, this method can only be overridden as protected or private.
It can be protected
or public
. I think the first one is obvious that it can. Just as a daughter class can have new members that it did not have in the mother it becomes clear that an existing method with restricted visibility can appear with a more liberal visibility, ie it is as if it were a new member with total visibility, public
. This already demonstrates an error in the question. But the opposite indicates more error yet. A daughter class can not fail to have a member that existed in the parent class, to be a object equal to the mother it needs to have everything that already existed before. When you decrease the visibility you make with a member that was quite visible is not visible in all situations, so it is common if that member ceases to exist in certain scenarios, which would render the object incompatible with what is expected of it. This is formally defined by the Liskov principle .
But in addition to this the polymorphism only makes sense in members proteced
and public
, a private member by definition is an implementation details and belongs only to the class in which it was defined, can not pass to another, in this case even in parent class this would be a problem.
If it did not exist polymorphism could do this because they would be distinct methods and there Liskov does not apply. But the existence of the superscript term in the text makes it clear that there is polymorphism.