| |
GeekInterview.com > Interview Questions > Concepts > OOPS
| Print | |
Question: Describe the principles of OOPS
Answer: There are three main principals of oops which are called Polymorphism, Inheritance and Encapsulation |
| August 08, 2005 18:13:39 |
#2 |
| Paul |
Member Since: Visitor Total Comments: N/A |
RE: Describe the principles of OOPS |
Polymorphism This ability of different objects to respond, each in its own way, to identical messages is called polymorphism. Polymorphism results from the fact that every class lives in its own name space. The names assigned within a class definition won't conflict with names assigned anywhere outside it. This is true both of the instance variables in an object's data structure and of the object's methods: Just as the fields of a C structure are in a protected name space, so are an object's instance variables. Method names are also protected. Unlike the names of C functions, method names aren't global symbols. The name of a method in one class can't conflict with method names in other classes; two very different classes could implement identically named methods. Method names are part of an object's interface. When a message is sent requesting an object to do something, the message names the method the object should perform. Because different objects can have different methods with the same name, the meaning of a message must be understood relative to the particular object that receives the message. The same message sent to two different objects could invoke two different methods. The main benefit of polymorphism is that it simplifies the programming interface. It permits conventions to be established that can be reused in class after class. Instead of inventing a new name for each new function you add to a program, the same names can be reused. The programming interface can be described as a set of abstract behaviors, quite apart from the classes that implement them. |
| |
Back To Question | |