private
and writing public
methods in the class to set and get the values of variables.
If one task is performed in different ways, it is known as polymorphism. For example, a salesman may draw something (such as shape, triangle, rectangle, etc.) differently to convince the customer. In Java, we use method overloading and overriding to achieve polymorphism. Another example is to speak something in different ways; for example, a cat speaks meow, dog barks woof, etc. |
private
, protected
, and public
modifiers to display the visibility level of a class, method, and field.
You can use interfaces for the weaker coupling because there is no concrete implementation.
A recent immigrant from Poland needed a drivers license, and went to the state licensing bureau. When it was time for his eye test, the examiner asked him to read a chart of small letters: “Can I read it?” said the immigrant. “That guy is my best friend.” |