Object Oriented Programming 2017-18 Previous Year Paper Solution
Short Questions

Q2. Answer the following questions: Short answer type [Marks: 2 x 10]

a) What are the basic concepts of oops?

Ans: There are 4 basic concepts that make an language Object Oriented. These are Encapsulation, Data Abstraction, Polymorphism and Inheritance.

 These are the four pillars of any Object Oriented Programming language.


b) What will be the output of following codes.

x = 6;
cout <<x<<x++<<++x;

Ans: Output: 668

c) Define comma operator and its use with example.

Ans: (,) comma can be used as an operator. Its a binary operator. The value of a comma-separated list of expressions is the value of the rightmost expression.

d) Differentiate between encapsulation and abstraction.

Ans: Difference between Encapsulation and Abstraction:

1. Abstraction solve the problem in design level.1. Encapsulation solves the problem in implementation level.
2. Abstraction is used for hiding the unwanted data and giving relevant data.2. Encapsulation means hiding the code and data into a single unit to protect the data from outside world.

e) When do we declare a member of class static?

Ans: If we declare a Variable(data member) as static, only One memory is allocated for this variable regardless of many objects of that variable. It means many objects share single memory.

We use a keyword “static” to declare a member of class static as shown in the below code:

class Test 
    static A a; 
    Test() { cout << "Constructor Called" << endl; } 

f) How dynamic initialization of objects is achieved?

Ans: Dynamic initialization of objects can be achieved using parameterized constructors in C++.

Example Code:

#include <iostream>
using namespace std;
class Test{
   int a , b;
      Test(int x, int y) {
         a= x;
         b= y;
      void Sum( ) {
         cout<<"Sum is ="<< a + b ;
int main() {
   int x, y;
   Test obj(10,20);//dynamic initialization
   return 1;

g) What is friend function? What is importance in OOP?

Ans: A friend function in C++ is a function that is preceded by the keyword “friend”. When the function is declared as a friend, then it can access the private and protected data members of the class.

h) Define manipulators with its example.


i) Explain the concept of Overriding with example.


j) What are different blocks used in exception handling.