Thursday, May 5, 2011

Object Oriented Programming Concepts


1. What is OOPS ?
Object-oriented programming (OOP) is a programming paradigm using "objects" (data structures consisting of data fields and methods together with their interactions) to design applications and computer programs.

2.What is an Object?

>> An object is an instance of a class.
>> An object can be considered a "thing" that can perform a set of related activities.
>> There are three properties of an object viz.
a. Identity
b. State
c. Behaviour

3.What is a Class?
>> A class is the blueprint from which the individual objects are created. Class is composed of three things: a name, attributes, and operations.

>> A class defines the properties of the object and the methods used to control the object’s behaviour.

4.What is Encapsulation ?
Encapsulation implies that the non-essential details of an object are hidden from the user and an access its provided to its essential details.
>>eg: Computer games also use this feature. The user only needs to know how to play the game, the complex working of the game is hidden from the user.
Encapsulation is the feature that provides security to the data and the methods of a class.

5.What is Abstraction ?
Abstraction is a process of hiding  unwanted details from the user.
Abstraction also means ignoring the non-essential details of an object and concentrating on its essential details.

6.What is Inheritance ?
Inheritance enables you to extend the functionality of an existing class.
When you create a class that inherits another existing class, it will inherit the attributes and behavior of that class, plus it can also have new attributes and behavior that are specific to that class.
>>Advantage: Code-Resuability which result in saving time and energy.

7.What is Polymorphism ?
Polymorphism - Poly stands for many and morph means form. So any thing that exists in more than one form is known as polymorph.
In oops, polymorphism means assigning a  different meaning to an entity in different context.

8.Types of Inheritance ?

There are 5 types of inheritance,
a. Single Inheritence >> One Super Class and One Sub class.
b. Multiple Inheritance >> More than One Super Class and One Sub class
c. Multi Level Inheritance >> A Class which is a Sub class of One class,      becomes a Super class for another class.
d. Hierarchical Inheritance >> One Super Class and many Sub classes
e. Hybrid Inheritance >> Multiple and Multi level combined.

9.Types of Polymorphism ? 

>> There are two types of polymorphism 
1. Run Time Polymorphism
2. Compile time Polymorphism 
>> To achive the Compile Time polymorphism there two ways
1. Function Overloading
2. Operator Overloading
>> To achive the Runtime Polymorphism we need to use 
1. Virtual functions

Q. What is a Virtual Function ?

>> Virtual functions are normal member functions of a class, which can be over-ridden in the derived classes. The whole functionality can be replaced in the over-riding function.
>> In C#, the virtual functions will be declared with a keyword 'virtual' and the over-riding functions will be declared with 'override' key word.

Class Base_Class
public virtual void MyMethod(){}

Class Derived_Class:Base_Class
public override void MyMethod(){}

10. What is Serialization and De-Serialization?

Serialization is the process of converting an object into a series of bytes for transmitting or storing purpose. Deserialization is a process, where these same bytes are converted back into objects.

11.What is an Abstract Class ?
>> Abstract class is a class which cannot be instantiated but it is inherited by derived classes. This class contains abstract as well as non-abstract methods and members.

>> Any concrete class (i.e not abstract) inheriting an abstract class MUST implement ALL inherited abstract method.

12. What is an Interface ?
>> Interface is a contract for what a class MUST do, but it does not specify the way it should be done.
>> An interface contains only the signatures of methods (only the declaration). A class implementing the interface must implement all the members of the interface (i.e provide the definations for those methods).
>> Interface separates the implementation and defines the structure, and this concept is very useful in cases where you need the implementation to be flexible.
>> Interfaces can inherit other (many) Interfaces.
>> A Class can implement many Interfaces.

13. Abstract class vs. Interface
>> An abstract class can have abstract members as well non abstract members. But in an interface all the members are implicitly abstract and all the members of the interface must be overriden in its derived class.
>> A class can inherit one or more interfaces, but only one abstract class.
>> An abstract class can have 0 abstract method.
>> Abstract class can have fields (such as int, string etc) , whereas Interface cannot.

14. Garbage Collection (Finalize, Dispose Methods)

15. What are Wrapper Classes.

16. What are Threads.



Post a Comment


2011 ·Code-Studio by yrus.