Sep 13, 2012

From Today we will be adding a new Category in www.visualstudiolearn.com with the Name "Interview Questions".In this Category we will try to share all important , Technical and mostly asked Question by interviewer during Interview or Tests that is faced by fresh graduates when they go for jobs during Interviews at Different Software Houses or I.T forums .Today i will be discussing a most frequently asked question in interviews What is Object oriented Programming and What are basic pillars of OOP.So Lets Starts:What is Object oriented Programming Object-oriented programming (OOP) is a programming language model organized around "objects" rather than "actions" and data rather than logic. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data.The programming challenge was seen as how to write the logic, not how to define the data.OOP is a design philosophy, uses a different set of programming languages than old procedural programming languages (C, Pascal, etc.). Everything in OOP is grouped as self sustainable "objects". Hence, you gain re-usability. What are basic pillars of OOP.There are (5) five Basic Pillars of OOP.1) Re-usability.

Classes

Objects

2) Encapsulation.3) Inheritance4) Abstraction5) Poly-morphism 1) Re-usability. By using OOP we can re use code again and Again.Two basic Factors for code Re-usability are given Below.i) Class:A class is a custom user defined data type that defines the characteristics of a thing (object's fields or properties) and the behavior of the thing (methods).Object-oriented languages allow the programmers to define data types that represent.A class is simply a representation of a type of object. It is the blueprint/ plan/ template that describe the details of an object. A class is the blueprint from which the individual objects are created. Class is composed of three things: a name, attributes, and operations.ii) Objects :An object can be considered a "thing" that can perform a set of related activities. The set of activities that the object performs defines the object's behavior. For example, the hand can grip something or a Student (object) can give the name or address.It is a real time entity.In pure OOP terms an object is an instance of a class.Below is an Example of Class and Object.

2) Encapsulation: Encapsulation is the ability of hiding object's internal implementation (By using private , public, protected key words with class , data types at initializing ), is a process of binding the data members and member functions into a single unit.3) Inheritance :The ability of building a new class definition based on existing class definition (Mean Inherit Some thing from which is Already Existing) . Inheritance is one of the Basic Pillar or primary concepts of object-oriented programming. It allows you to reuse existing code. Through effective use of inheritance, you can save lot of time in your programming and also reduce errors, which in turn will increase the quality of work and productivity.

4) Abstraction:Abstraction is a process of hiding the implementation details and displaying the essential features.
Example1: A Laptop consists of many things such as processor, motherboard, RAM, keyboard, LCD screen, wireless antenna, web camera, usb ports, battery, speakers etc. To use it, you don't need to know how internally LCD screens, keyboard, web camera, battery, wireless antenna, speaker’s works. You just need to know how to operate the laptop by switching it on. Think about if you would have to call to the engineer who knows all internal details of the laptop before operating it. This would have highly expensive as well as not easy to use everywhere by everyone.
The importance of abstraction is derived from its ability to hide irrelevant details and from the use of names to reference objects.While abstraction reduces complexity by hiding irrelevant details.

5) Polymorphism Polymorphism gives you the ability of treating related objects the same way. When a message can be processed in different ways is called polymorphism. Polymorphism means many forms.Polymorphism is one of the fundamental of OOP.Polymorphism provides following features:

It allows you to invoke methods of derived class through base class reference during runtime.

It has the ability for classes to provide different implementations of methods that are called through the same name.

That's all for today. Tune in next time for more conceptual analysis and terms used in core programming. Hope these help you out during interviews.