Tuesday

Class 12 - Computer Science with C++ Question Answers Chapter -OBJECT ORIENTED PROGRAMMING

 

1. What are programming paradigms? Give names of some popular programming paradigms.

Ans:

Programming Paradigm: A Programming Paradigm defines the methodology of designing and implementing programs using the key features and building blocks of a programming language. Following are the different programming paradigms: (i) Procedural Programming (ii) Object Based Programming (iii) Object Oriented Programming


2. Write a short note on OO programming.

Ans:

OOP stands for Object Oriented Programming. In, Object-Oriented Programming (OOP), the program is organized around the data being operated upon rather than the operations performed. The basic idea behind OOP is to combine both, data and its functions that operate on the data into a single unit called object. Following are the basic OOP concepts: 1. Data Abstraction 2. Data Encapsulation 3. Modularity 4. Inheritance 5. Polymorphism


3. Write a short note on inheritance.

Ans:

Inheritance enables us to create new classes that reuse, extend, and modify the behavior that is defined in other classes. The class whose members are inherited is called the base class, and the class that inherits those members is called the derived class. A derived class can have only one direct base class. Inheritance is transitive. When we define a class to derive from another class, the derived class implicitly gains all the members of the base class, except for its constructors and destructors.

4. What is the significance of private, protected and public specifiers in a class?

Ans:

A class groups its members into three sections: private, protected, and public. The private and protected members remain hidden from outside world. Thus through private and protected members, a class enforces data-hiding. The public members are accessible everywhere in a program.

5. Encapsulation is one of the major properties of OOP. How is it implemented in C++?

Ans:

A class binds together data and its associated functions under one unit thereby enforcing encapsulation as encapsulation means wrapping up data and associated functions together into a single unit. While implementing encapsulation, following things are taken care of: (i) Anything that an object does not know or cannot do is excluded from the objects. (ii) Encapsulation is used to hide unimportant implementation details from other objects. (iii) The data and associated functions are wrapped up in one unit called class. Through encapsulation, an interface is made available to world through which users can use the class.  

0 comments:

Post a Comment

Thanks for leaving a comment. As soon as it's approved, it will appear.