answersLogoWhite

0

Some of the key OOPS principles are:

Encapsulation - The ability to make changes in your code without breaking the code of all others who use your code is a key benefit of encapsulation. You should always hide implementation details. To elaborate, you must always have your variables as private and then have a set of public methods that others can use to access your variables. Since the methods are public anyone can access them, but since they are in your class you can ensure that the code works the way that is best for you. So in a situation that you want to alter your code, all you have to do is modify your methods. No one gets hurt because i am just using your method names in my code and the code inside your method doesnt bother me much.

If you want maintainability, flexibility, and extensibility (and I guess, you do), your design must include encapsulation. You do that by:

• Keep instance variables protected (with an access modifier, mostly private).

• Make public accessor methods, and force calling code to use those methods rather than directly accessing the instance variable.

• For the methods, use the JavaBeans naming convention of set and get.

Inheritance - Inheritance is the feature by which functionality in one class is used in another class. It creates a parent child relationship between classes.

Polymorphism - Polymorphism refers to the feature wherein the same entity exists as multiple items. Ex: method overriding, method overloading etc.

User Avatar

Wiki User

14y ago

What else can I help you with?