Object-oriented programming (OOP) is a programming language model organized around objects. At this poing you may have a question in your mind, what is an object? its simple, an object can be anything which has some attributes and hehaviour. For example, hope now you are infront of a computer monitor, the monitor itself is an object, it has a lot of attributes like Make, Size, Type etc...
In OOP we use classes and objects to represent our data and logic. For example consider the following C# example.
The above class defines a structure of the computer monitor. An object of this class can represent a computer monitor.
public class Monitor
{
public string Make
{
set;
get;
}
public int Height
{
set;
get;
}
//etc......
}
OOP Concepts
- Data Abstraction : The act of representing essential features without showing the back ground details.
- Data Encapsulation: The wrapping up of data together into a single unit.
- Inheritance: The act of inheriting properties of an object into another.
- Polymorphism: The ability of a data to behave in multiple forms.
Possible questions about OOP concepts from a .NET stand point are:
- What is Data Abstraction? ans: see above definition
- What is Encapsulation? ans: see above definition
- What is inheritance? ans: see above definition
- What is Polymorphism? ans: see above definition
- Does .Net support multiple inheritance? ans: no
- Example for polymorphism? ans:function overloading, overriding and operator overloading
- Real world example for data abstraction? ans: when we press the start switch of a car or bike will get started, we might not need to know the internal process. we gave an input and we got an outcome.
- What is a class and an object? ans: class is a blueprint for creating objects. An object is an instance of a class and it have the properties and behaviours defined in the class.
No comments:
Post a Comment