Describe the principles of OOPS

There are three main principals of oops which are called Polymorphism, Inheritance and Encapsulation

Showing Answers 1 - 36 of 36 Answers

Ayan

  • Aug 4th, 2005
 

I think the define needsbit more ellustrationn...??

Paul

  • Aug 4th, 2005
 

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.

Paul

  • Aug 4th, 2005
 

Inheritance  
 
The easiest way to explain something new is to start with something old. If you want to describe what a ``schooner'' is, it helps if your listeners already know what ``sailboat'' means. If you want to explain how a harpsichord works, it's best if you can assume your audience has already looked inside a piano, or has seen a guitar played, or at least is familiar with the idea of a ``musical instrument.'' 
 
The same is true if want to define a new kind of object; the description is simpler if it can start from the definition of an existing object. 
 
With this in mind, object-oriented programming languages permit you to base a new class definition on a class already defined. The base class is called a superclass; the new class is its subclass. The subclass definition specifies only how it differs from the superclass; everything else is taken to be the same. 
 
Nothing is copied from superclass to subclass. Instead, the two classes are connected so that the subclass inherits all the methods and instance variables of its superclass, much as you want your listener's understanding of ``schooner'' to inherit what they already know about sailboats. If the subclass definition were empty (if it didn't define any instance variables or methods of its own), the two classes would be identical (except for their names) and share the same definition. It would be like explaining what a ``fiddle'' is by saying that it's exactly the same as a ``violin.'' However, the reason for declaring a subclass isn't to generate synonyms, but to create something at least a little different from its superclass. You'd want to let the fiddle play bluegrass in addition to classical music.

Paul

  • Aug 4th, 2005
 

Encapsulation  
 
To design effectively at any level of abstraction, you need to be able to leave details of implementation behind and think in terms of units that group those details under a common interface. For a programming unit to be truly effective, the barrier between interface and implementation must be absolute. The interface must encapsulate the implementation--hide it from other parts of the program. Encapsulation protects an implementation from unintended actions and inadvertent access. 
In C, a function is clearly encapsulated; its implementation is inaccessible to other parts of the program and protected from whatever actions might be taken outside the body of the function. Method implementations are similarly encapsulated, but, more importantly, so are an object's instance variables. They're hidden inside the object and invisible outside it. The encapsulation of instance variables is sometimes also called information hiding. 
 
It might seem, at first, that hiding the information in instance variables would constrain your freedom as a programmer. Actually, it gives you more room to act and frees you from constraints that might otherwise be imposed. If any part of an object's implementation could leak out and become accessible or a concern to other parts of the program, it would tie the hands both of the object's implementor and of those who would use the object. Neither could make modifications without first checking with the other. 
 
Suppose, for example, that you're interested in the Faucet object being developed for the program that models water use and you want to incorporate it in another program you're writing. Once the interface to the object is decided, you don't have to be concerned as others work on it, fix bugs, and find better ways to implement it. You'll get the benefit of these improvements, but none of them will affect what you do in your program. Because you're depending solely on the interface, nothing they do can break your code. Your program is insulated from the object's implementation. 
 
Moreover, although those implementing the Faucet object would be interested in how you're using the class and might try to make sure that it meet your needs, they don't have to be concerned with the way you're writing your code. Nothing you do can touch the implementation of the object or limit their freedom to make changes in future releases. The implementation is insulated from anything that you or other users of the object might do.

kapil madhur

  • Oct 5th, 2005
 

there is four methods of oops which is polymorphim,abstraction,enheritence,encapsulation

M.Rajarajeswari

  • Nov 26th, 2005
 

Polymorphism,Inheritence,Encapsulation,Method overloading and Method overriding,those above are the five principles.

Matt Filion

  • Mar 8th, 2006
 

There are 4 principles of OOP. Abstraction, Ineheritance, Polymorhpism and Encapsulation.

Method Overloading and Overriding are a part of the Polymorphism principle.

preeti

  • Sep 25th, 2006
 

And how would you define Abstraction?

Udhaya Kumar.D

  • Nov 24th, 2006
 

Abstraction: An abstract class is a parent class that allows inheritance but can never be instantiated. Abstract classes contain one or more abstract methods that do not have implementation. These abstract methods can be defined in the derived class. Example :public abstract class Parent{ public abstract void add();}public class child : Parent{ public override void add() { }}And not like this:public abstract class Parent{ public abstract void add() { }}public class child : Parent{ public override void add() { }}

umashankar C. Yadav

  • Nov 25th, 2006
 

The four basic principles of OOPS are

Abstraction, Encapsulation, Modularity, Heirarchy

skonealone

  • Mar 8th, 2007
 

hey guys
as the question says.. here i am giving some details answer of dem..
here its goes..hope this will helpful to u all...

  • Objects
  • Classes
  • Inheritance
  • Data Abstraction
  • Data Encapsulation
  • Polymorphism
  • Overloading
  • Reusability

Let us see the concept of each briefly.

Objects:

This is the basic unit of object oriented programming. That is both data and function that operate on data are bundled as a unit called as object.

Classes:

The concept of class is similar to the concept of structure in C. In other words classes are the data types on which objects are created. So while a class is created no memory is allocated only when an object is created memory gets allocated.

Inheritance:

As the name suggests Inheritance is the process of forming a new class from an existing class that is from the existing class called as base class, new class is formed called as derived class. This is a very important concept of object oriented programming since this feature helps to reduce the code size.

Data Abstraction:

By this feature of object oriented programming it is possible to represent the needed information in program without presenting the details. Also by the feature of data abstraction it is possible to create user defined data types and thus increase the power of programming language.

Data Encapsulation:

Data Encapsulation is the process of combining data and functions into a single unit called class. By this method one cannot access the data directly. Data is accessible only through the functions present inside the class. Thus Data Encapsulation gave rise to the important concept of data hiding.

Polymorphism:

The ability to use an operator or function in different ways in other words giving different meaning or functions to the operators or functions is called polymorphism. Poly refers many. That is a single function or an operator functioning in many ways different upon the usage is called polymorphism.

Overloading:

The concept of overloading is also a branch of polymorphism. When the exiting operator or function is made to operate on new data type it is said to be overloaded.

Reusability:

That is object oriented programming has the feature of allowing an existing class which is written and debugged to be used by other programmers and there by provides a great time saving and also code efficiency to the language. Also it is possible to a have the existing class and adds new features to the existing class as pet the programmer’s choice.

Thus the object oriented programming features helps the program ad there by users of the application to achieve increased performance, it saves time of developing the application, give optimized code for the application, helps in gaining secured applications and there by helps in easier maintenance.


--
skonealone

Raj Sampad

  • Mar 24th, 2007
 

 They are -

Objects
Class
Data Hiding
Inheritance
Polymorphism
Abstraction
Dynamic Binding
Encapsulation

Quest_For_Knowledge

  • Jul 14th, 2007
 

Abstraction is not a principle of OOP, but it's an application of the concepts of OOP. Don't mistake abstraction to be a concept of OOP. Abstraction is basically a result of Encapsulation and Polymorphism. Predominantly encapsulation is concerned with information hiding and these two terms can be used interchageably. Abstraction leads to modules which result in reuseable OO software. This is what OOP is all about. There is no good OOP design without encapsulation and polymorphism.

 main principal of OOPS are

  1. Encapsulation :  binding the data and function in a unit called class is called a data encapsulation. this allow the user to hide the information for outside world and doesn't allow the other user to change or modify the internal values of class.
  2. Polymorphism: polymorphism is another strong feature of OOPS. it means one term in many forms.
  3. Inheritance: another strong property of OOPS. this feature offers to derive a new class from an existing one and acquire all the feature of the existing class the new class which get the feature from existing class called derived class and other class is called base class.

snvgram

  • Jan 9th, 2009
 

The four basic principle of OOP are:
Abstraction
Encapsulation
Hierarchy
and Modularity

Please note that there are many other object oriented principles, but the above the are basic ones.
We can refer Class hierarchy as Inheritance.
If the language supports Encapsulation and Inheritance, Polymorphism can be achieved.

  Was this answer useful?  Yes

nkumar1095

  • Oct 8th, 2009
 

Abstraction: Involves extracting only the relevant information.

Encapsulation: Involves packaging one or more components together.

Inheritance: Is a process of creating a new class by adding some features to an existing class.

Polymorphism: Is an ability to react differently based on the information associated with the message. 

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions