Object Oriented Programming
Qus: How are objects implemented in software?
Ans: In a software the characteristics of an object are represented through data members and behaviour is represented through member functions.
Qus: What is Object Oriented Programming?
Ans: Object Oriented Programming (or OOP) is a technique of implementing programs which are organized as a co-interactive collection of objects, each of which represents an instance of a class.
Qus: State three differences between Procedure Oriented Language and Object Oriented Languages.
|Procedure Oriented Programming||Object Oriented Programming|
|A large program is divided into smaller segments or procedures.||A program is represented as an object.|
|More importance is given to the program rather than the data.||More importance is given to the data rather than the program.|
|It follows top down approach.||It follows bottom up approach.|
Qus: Give two examples of real world objects. Also specify their characteristics and behaviour.
Ans. The book that you are reading now is also an example of an object. Its characteristics is represented by the information it holds, size, volume and its colour. The behavioural aspect is referred by the methods for accessing the information it contains
A pen is also an example of object. Its characteristics is represented by its colour, shape, brand, etc., and its behaviour is represented by its use such as writing, drawing, etc.
Qus. What do you understand by state of an object? Explain with an example.
Ans. The state of an object is the particular condition it is in. For example, a lamp can be on or off. The lamp’s switch (methods) turn lamp on and turn lamp off are used to access the state of the lamp.
Qus: State the four characteristics/principles of Object Oriented Programming.
Ans: Encapsulation, Abstraction, Polymorphism and Inheritance.
Qus: Why is an object called an instance of a class?
Ans: An object is called an instance of a class as every object created from a class gets its own instances of the variables defined in the class. Multiple objects can be created from the same class.
Qus: What is Inheritance?
Ans: Inheritance is the concept that when a class of objects is defined, any subclass that is defined can inherit the definitions of one or more general classes.
Qus: What is abstraction? How is encapsulation related to it?
Ans: Abstraction is a principle of Object Oriented Programming (OOP) that hide certain details and only show the essential features of the object.
Encapsulation is also frequently confused with abstraction, since the two concepts are closely related. Abstraction is a process of hiding the complexity and giving a simple interface. Encapsulation on the other hand is the mechanism by which the abstraction is implemented.