Getter and setter methods (also known as accessors) are dangerous for the same reason that public fields are dangerous: They provide external access to implementation details . What if you need to change the accessed field’s type? You also have to change the accessor’s return type.
Read moreCan you inherit variables?
A subclass inherits variables and methods from its superclass and can use them as if they were declared within the subclass itself: class Animal { float weight ; …
Read moreWhich variables Cannot be inherited?
Static Methods or variables do not take part in inheritance. Even though static methods or variables do not take part in inheritance and cannot be overridden, they can be redefined in a subclass. The redefinition is not called overridden but hidden.
Read more