• NCERT Solutions
    • NCERT Library
  • RD Sharma
    • RD Sharma Class 12 Solutions
    • RD Sharma Class 11 Solutions Free PDF Download
    • RD Sharma Class 10 Solutions
    • RD Sharma Class 9 Solutions
    • RD Sharma Class 8 Solutions
    • RD Sharma Class 7 Solutions
    • RD Sharma Class 6 Solutions
  • Class 12
    • Class 12 Science
      • NCERT Solutions for Class 12 Maths
      • NCERT Solutions for Class 12 Physics
      • NCERT Solutions for Class 12 Chemistry
      • NCERT Solutions for Class 12 Biology
      • NCERT Solutions for Class 12 Economics
      • NCERT Solutions for Class 12 Computer Science (Python)
      • NCERT Solutions for Class 12 Computer Science (C++)
      • NCERT Solutions for Class 12 English
      • NCERT Solutions for Class 12 Hindi
    • Class 12 Commerce
      • NCERT Solutions for Class 12 Maths
      • NCERT Solutions for Class 12 Business Studies
      • NCERT Solutions for Class 12 Accountancy
      • NCERT Solutions for Class 12 Micro Economics
      • NCERT Solutions for Class 12 Macro Economics
      • NCERT Solutions for Class 12 Entrepreneurship
    • Class 12 Humanities
      • NCERT Solutions for Class 12 History
      • NCERT Solutions for Class 12 Political Science
      • NCERT Solutions for Class 12 Economics
      • NCERT Solutions for Class 12 Sociology
      • NCERT Solutions for Class 12 Psychology
  • Class 11
    • Class 11 Science
      • NCERT Solutions for Class 11 Maths
      • NCERT Solutions for Class 11 Physics
      • NCERT Solutions for Class 11 Chemistry
      • NCERT Solutions for Class 11 Biology
      • NCERT Solutions for Class 11 Economics
      • NCERT Solutions for Class 11 Computer Science (Python)
      • NCERT Solutions for Class 11 English
      • NCERT Solutions for Class 11 Hindi
    • Class 11 Commerce
      • NCERT Solutions for Class 11 Maths
      • NCERT Solutions for Class 11 Business Studies
      • NCERT Solutions for Class 11 Accountancy
      • NCERT Solutions for Class 11 Economics
      • NCERT Solutions for Class 11 Entrepreneurship
    • Class 11 Humanities
      • NCERT Solutions for Class 11 Psychology
      • NCERT Solutions for Class 11 Political Science
      • NCERT Solutions for Class 11 Economics
      • NCERT Solutions for Class 11 Indian Economic Development
  • Class 10
    • NCERT Solutions for Class 10 Maths
    • NCERT Solutions for Class 10 Science
    • NCERT Solutions for Class 10 Social Science
    • NCERT Solutions for Class 10 English
    • NCERT Solutions For Class 10 Hindi Sanchayan
    • NCERT Solutions For Class 10 Hindi Sparsh
    • NCERT Solutions For Class 10 Hindi Kshitiz
    • NCERT Solutions For Class 10 Hindi Kritika
    • NCERT Solutions for Class 10 Sanskrit
    • NCERT Solutions for Class 10 Foundation of Information Technology
  • Class 9
    • NCERT Solutions for Class 9 Maths
    • NCERT Solutions for Class 9 Science
    • NCERT Solutions for Class 9 Social Science
    • NCERT Solutions for Class 9 English
    • NCERT Solutions for Class 9 Hindi
    • NCERT Solutions for Class 9 Sanskrit
    • NCERT Solutions for Class 9 Foundation of IT
  • CBSE Sample Papers
    • Previous Year Question Papers
    • CBSE Topper Answer Sheet
    • CBSE Sample Papers for Class 12
    • CBSE Sample Papers for Class 11
    • CBSE Sample Papers for Class 10
    • CBSE Sample Papers for Class 9
    • CBSE Sample Papers Class 8
    • CBSE Sample Papers Class 7
    • CBSE Sample Papers Class 6
  • Textbook Solutions
    • Lakhmir Singh
    • Lakhmir Singh Class 10 Physics
    • Lakhmir Singh Class 10 Chemistry
    • Lakhmir Singh Class 10 Biology
    • Lakhmir Singh Class 9 Physics
    • Lakhmir Singh Class 9 Chemistry
    • PS Verma and VK Agarwal Biology Class 9 Solutions
    • Lakhmir Singh Science Class 8 Solutions

Learn CBSE

NCERT Solutions for Class 6, 7, 8, 9, 10, 11 and 12

Important Questions for Class 12 Computer Science (C++) – Object Oriented Programming

December 9, 2019 by Rama Krishna

Important Questions for Class 12 Computer Science (C++) – Object Oriented Programming

Previous Years Examination & Important Questions
2 Marks Questions

Question 1:
Write any four important characteristics of object oriented programming. Give example of any one of the characteristics using C++.  All India 2016
Answer:
Four important characteristics of object oriented programming are as follows:

(i) Data encapsulation
(ii) Inheritance
(iii) Polymorphism
(iv) Data abstraction

Example of Inheritance

Class Rectangle
{
::::
};
class Area : public Rectangle
{
::::
};

Question 2:
Explain data hiding with an example. All India 2014C
Answer:
Data hiding is a property, where internal data structure of an object is hidden from the outside world. Data hiding helps to secure the data. It is implemented with private and protected keywords. ,
e.g.

class Item
{
private:
int item_no; 
float item_cost; 
public:
void getdata(); 
void putdata();
};

Here, in this example variables item_no and item_cost are hidden, i.e. cannot be directly accessed from outside the class Item.

Question 3:
What is function overloading? Give an example in C++ to illustrate function overloading.
All India 2014,2009

or

What do you understand by function overloading? Give an example illustrating its use in a C++ program. All India 2009
Answer:
When several functions have same name but performing different tasks, then it is known as function overloading. The definitions of these functions are differentiable by the number or types of their arguments.
e.g.

float compute(float radius)
{
return(3.14*radius*radius);
}
float compute(float l, float b)
{
return(l*b)
}
float compute (int b, float h) 
{
 return(0.5*b*h);
}

Question 4:
Write the output of the following C++ code. Also, write the name of feature of Object Oriented Programming used in the following program jointly illustrated by the functions [I] to [IV]. Delhi 2011

#include<iostream.h>
void Print() //Function[I]
{
for(int K=1; K<=60; K++) 
cout<<"-"; 
cout<<endl;
}
void Print(int N) //Function[II]
{
for(int K=1; K<=N; K++) 
cout<<"*"; 
cout<<endl;
}
void Print(int A, int B)//Function[III]
}
for(int K=1; K<=B; K++)
cout<<A*K; 
cout<<endl;
}
void Print(char T, int N)//Function[IV]
{
for(int K=l; K<=N; K++) 
cout<<T; 
cout<<endl;
}
void main!)
{
int U=9, V=4, W=3; 
char C= '@';
Print(C, V);
Print(U, W);
}

Answer:
Feature of C++→ Function overloading The output will be:
@@@@
91827

Question 5:
Write the output of the following C++ code. Also, write the name of feature of Object Oriented Programming used in the following program jointly illustrated by the functions [I] to [IV]: All India 2011

#include<iostream.h>
 void Lined //Function[I]
 {
 for(int L=1;L<=80;L++)
 cout<<"-";
 cout<<endl;
 }
 void Line(int N) //Function[II]
 {
 for(int L=1;L<=N;L++)
 cout«"*";
 cout<<endl:
 }
 void Line(char C,int N) //Function[III]
 {
 for(int L=1:L<=N:L++)
 cout<<C;
 cout<<endl:
 }
 void Line(int M, int N)//Function[IV]
 {
 for(int L=1:L<N;L++)
 cout<<M*L;
 cout<<endl;
 }
 void main()
 {
 int A=9, B=4, C=3;
 char K=’#':
 Line (K,B);
 Line (A,C);

Answer:
Feature of C ++ Function overloading Output will be :
####
91827

Question 6:
What do you understand by Data Encapsulation and Data Hiding? Also, give an example in C++ to illustrate
both. All India 2010
Answer:
Data Encapsulation
The wrapping up of data (member variables) and functions into a single unit is known as data encapsulation. Encapsulation is implemented in C ++ with the help of classes.
Data Hiding
When member data and member function are binded into a single unit then the data is not accessible to the outside world and only those functions, which are wrapped in that class can access it. Data hiding is implemented in C+ + with the help of private and protected keywords.
e.g.
Important Questions for Class 12 Computer Science (C++) - Object Oriented Programming

Question 7:
What do you understand by polymorphism? Give an example illustrating its use in a C++ program. Delhi 2010
Answer:
Polymorphism means processing of data or messages in more than one form. C ++ implements polymoiphism through overloaded functions and overloaded operators,
e.g.

float compute(float a)
{
return a*a;
}
float computer float a,float b)
{
return(a*b); 
}

Question 8:
How are abstraction and encapsulation interrelated? Delhi 2009
Answer:
Abstraction refers to the representation of only the essential features of the real-world object in the program. This process does not include the background details and explanations. This concept of abstraction is used in classes whereas, data encapsulation is the most significant characteristic of the class. By this term, we mean the wrapping up of data and functions which operate on the data, into a single unit called the class. This encapsulation prevents free access to the data within an object.

Question 9:
What is event driven programming?
Answer:
In event driven programming, the user indicates the order of program execution not the programmer. Instead of, the program ‘driving’ the user ‘drives’ the program. Programming, in which the code that responds to the event is called event driven programming.

Question 10:
What is the significance of classes in OOPs?
Answer:
The classes are the manufacturing units of the objects of their type, i.e. it is the class that can be used to create an object. Classes are user defined data types and behave like the built-in types of a programming language. Classes are the basic building blocks of object oriented programming.

Question 11:
What are the advantages of object oriented programming over procedural oriented programming?
Answer:
Advantages of Object Oriented Programming (OOP) over Procedural Oriented Programming (POP)

Object Oriented Programming Procedural Oriented Programming
In OOP, program is divided into parts called objects. In POP, program is divided into small parts called functions.
OOP follows bottom up approach. POP follows top down approach.
OOP provides data hiding that provides more security. POP does not have any proper way for data hiding so it is less secure.
C++, Java, VB.NET, C, .NET, etc. are the examples of OOP language. C, VB, FORTRAN, Pascal etc are the examples of POP language.

Question 12:
Encapsulation is one of the major properties of OOP. How is it implemented in C++? HOTS

or

Define the term data encapsulation in terms of object oriented programming. Give a suitable example using a C++ code to illustrate the same.
Answer:
The wrapping up of data and functions into a single unit is called data encapsulation. That single unit is known as class.
e.g.

class person 
{
char name[30]; 
int age; 
public:
void getdata(void); 
void display(void);
};

The above program implements data hiding as data can’t be accessed directly from outside.

Question 13:
What is operator overloading? Explain with example.
Answer:
The process of making an operator to exhibit or show different behaviour in different situations is called as operator overloading.
e.g. consider the operation of (+) operator. Operation is sum, if operands are integer type and the operation is concatenation, if operands are strings.

Computer ScienceImportant Questions for Computer ScienceNCERT Solutions

Filed Under: CBSE

LearnCBSE Sample Papers
  • Words by Length
  • NEET MCQ
  • Factoring Calculator
  • Rational Numbers
  • CGPA Calculator
  • TOP Universities in India
  • TOP Engineering Colleges in India
  • TOP Pharmacy Colleges in India
  • Coding for Kids
  • Math Riddles for Kids with Answers
  • General Knowledge for Kids
  • General Knowledge
  • Scholarships for Students
  • NSP - National Scholarip Portal
  • Class 12 Maths NCERT Solutions
  • Class 11 Maths NCERT Solutions
  • NCERT Solutions for Class 10 Maths
  • NCERT Solutions for Class 9 Maths
  • NCERT Solutions for Class 8 Maths
  • NCERT Solutions for Class 7 Maths
  • NCERT Solutions for Class 6 Maths
  • NCERT Solutions for Class 6 Science
  • NCERT Solutions for Class 7 Science
  • NCERT Solutions for Class 8 Science
  • NCERT Solutions for Class 9 Science
  • NCERT Solutions for Class 10 Science
  • NCERT Solutions for Class 11 Physics
  • NCERT Solutions for Class 11 Chemistry
  • NCERT Solutions for Class 12 Physics
  • NCERT Solutions for Class 12 Chemistry
  • NCERT Solutions for Class 10 Science Chapter 1
  • NCERT Solutions for Class 10 Science Chapter 2
  • Metals and Nonmetals Class 10
  • carbon and its compounds class 10
  • Periodic Classification of Elements Class 10
  • Life Process Class 10
  • NCERT Solutions for Class 10 Science Chapter 7
  • NCERT Solutions for Class 10 Science Chapter 8
  • NCERT Solutions for Class 10 Science Chapter 9
  • NCERT Solutions for Class 10 Science Chapter 10
  • NCERT Solutions for Class 10 Science Chapter 11
  • NCERT Solutions for Class 10 Science Chapter 12
  • NCERT Solutions for Class 10 Science Chapter 13
  • NCERT Solutions for Class 10 Science Chapter 14
  • NCERT Solutions for Class 10 Science Chapter 15
  • NCERT Solutions for Class 10 Science Chapter 16

Free Resources

RD Sharma Class 12 Solutions RD Sharma Class 11
RD Sharma Class 10 RD Sharma Class 9
RD Sharma Class 8 RD Sharma Class 7
CBSE Previous Year Question Papers Class 12 CBSE Previous Year Question Papers Class 10
NCERT Books Maths Formulas
CBSE Sample Papers Vedic Maths
NCERT Library

 

NCERT Solutions

NCERT Solutions for Class 10
NCERT Solutions for Class 9
NCERT Solutions for Class 8
NCERT Solutions for Class 7
NCERT Solutions for Class 6
NCERT Solutions for Class 5
NCERT Solutions for Class 4
NCERT Solutions for Class 3
NCERT Solutions for Class 2
NCERT Solutions for Class 1

Quick Resources

English Grammar Hindi Grammar
Textbook Solutions Maths NCERT Solutions
Science NCERT Solutions Social Science NCERT Solutions
English Solutions Hindi NCERT Solutions
NCERT Exemplar Problems Engineering Entrance Exams
Like us on Facebook Follow us on Twitter
Watch Youtube Videos NCERT Solutions App