0% found this document useful (0 votes)
308 views

Questionbank CPP

This document contains a question bank with multiple choice and short answer questions about object oriented programming in C++. There are questions about basic OOP concepts like classes, objects, inheritance, polymorphism, encapsulation. There are also questions about C++ specific features like constructors, destructors, function overloading, operator overloading, file handling etc. The document contains sample programs to practice various OOP concepts in C++.

Uploaded by

Home Automation
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
308 views

Questionbank CPP

This document contains a question bank with multiple choice and short answer questions about object oriented programming in C++. There are questions about basic OOP concepts like classes, objects, inheritance, polymorphism, encapsulation. There are also questions about C++ specific features like constructors, destructors, function overloading, operator overloading, file handling etc. The document contains sample programs to practice various OOP concepts in C++.

Uploaded by

Home Automation
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Anekant Education Society’s

TuljaramChaturchand College of Arts, Science & Commerce, Baramati


Department of BBA(C.A)
FYBBA (C.A) (Semester - II)
Question Bank
Object Oriented Programming Using C++ [1201]

Q1. Multiple Choice Questions


1) The binding of data & functions into a single unit is called as
a) Class b) Dynamic Binding c) Encapsulation
2) In case of OOP the focus is on
a) Data b) Procedures c) Inheritance
3) The ability of a function or operator to act in different ways of different ways on
different data types is called as
a) Inheritance b) Overloading c) Encapsulation
4) The process of building a new classes from existing ones is called as
a) Inheritance b) Dynamic Binding c) Overloading
5) Which stream is used to input values to variables in the program?
a) Cin b) Cout c) main
6) Which stream is used to display output?
b) Cin b) Cout c) main
7) The values placed within the parentheses of a function are called
a) Arguments b) Statements c) Escape Sequence
8) Which of the following terms describes data that remains the same throughout a
program?

a) Constant b) Variable c) Integer

9) Which of the following statements are true with respect to the use of friend keyword \

Inside a class?
a) A private data member can be declared as a friend

b) A function may be declared as a friend

c) A class may be declared as a friend

10) What are the functions that can have access to the protected members of a class?

a) A function that is a friend of the class

b) A member function of a class that is a friend of the class

c) A member function of a derived class

11) In a class, all members are _________ by default.

a) Public b) Private c) Protected

12) Member functions of a class are normally declared as

a) Public b) Private c) Protected

13) Whenever an object is destroyed which function is called?

a) Constructor b) Destructor c) Copy Constructor

14) To request dynamic memory which operator is used?

a) New b) Destructor c) Delete

15) _______ is used to destroy a memory space.

a) New b) Destructor c) Delete

16) A _________ has the same name as that of class.

a) Constructor b) Destructor c) Delete

17) Which of the following way is legal to access a class data member using the this

Pointer?

a) this->x b) this.x c) this+x


18) From the following list which operator is not overloaded?

a) Conditional Operator b) Comma Operator c) Division Operator

19) C++ program can not run if __________ function not in the program.

a) Inline b) Main c) Friend

20) Function overloading is the concept of_____________

a) Inheritance b) Polymorphism c) Data Hiding

21) Which parameter is used for go to end of file?

a) ios::ate b) ios::in c) ios::out

22) Which concept allows you to reuse the written code?


a) Encapsulation b) Abstraction c) Inheritance
23) What is a friend function in C++?
a) A function which can access all the private, protected and public members of a class
b) A function which is allowed to access public and protected members of a class
c) A function which is allowed to access only public members of a class

24) Which keyword is used to represent a friend function?


a) friend
b) Friend
c) Friend_func

25) Which value will it take when both user and default values are given?
a) user value
b) default value
c) custom value

Q2. Answer the following in one or two lines


1) Define constructor. List the types of constructor.
2) What is virtual base class?
3) Define polymorphism. How is compile time polymorphism achieved?
4) List any four modes of opening a file.
5) What is the difference between ‘call by value’ and ‘call by reference’?
6) List any two advantages of C++ over C.
7) What is the difference between normal function and static function?
8) What do you mean by cascading of I/O operators?
9) Why are manipulators used? Which file should be included while using manipulators?
10) What is exception handling? What are the keywords used in exception handling?
11) List the types of inheritance.
12) Is there a need to call a constructor function explicitly? Jstify.
13) What is this pointer?
14) Define the term Class.
15) Define the term Encapsulation.
16) What is stream? Enlist various stream classes.
17) Define const member function.
18) What is class template?
19) List the situation where inline function does not work.
20) Define eof() function.
21) What is friend function?
22) What is function prototype?
23) Write any two advantages of inheritance.
24) Write any four operators that can be overloaded.
25) What is fstream?
26) Define constructor.
27) What is the use of setw and endl?
28) What is pure virtual function?
29) What is the use of this pointer?
30) What is reference variable.
Q3) Give answer of the following
1) Explain features of object oriented programming language?
2) Explain how to pass default argument with the help of suitable example and also write
in which situation default arguments are used?
3) How is memory allocated dynamically in C++? Explain.
4) Explain the use of setw(),setprecision(),setiosflags() and setfill() manipulators with
the help of suitable example.
5) Write note on constructors in derived class.
6) What is inline function? Explain with example.
7) Explain the functions of manipulation of file pointers.
8) Explain the characteristics of friend function.
9) Explain unary and binary operator overloading with the help of member functions.
10) Write a note on static data member.
11) Differentiate between C and C++.
12) What is function overloading. Write the steps to find unique match during
compilation.
13) Explain the structure of C++ program with the example.
14) What are the rules for defining virtual function?
15) Define inheritance. Explain the visibility scope of private, public and protected access
specifiers.
16) What is constructor? Explain default constructor and copy constructor.
17) Define file. Explain different ways to open a file.
18) Explain different uses of scope resolution operator in C++.
19) What is inline function? Write advantages of inline function overmacros.
20) Explain abstract class with the help of suitable example.
21) What is constructor? Give any four special characteristics of constructor.
22) Explain any four characteristics of friend function.
23) What is file mode? Explain any four file modes supported by C++.
24) How exceptions are handled in C++.
25) Explain rules of operator overloading.
Q4) Write programs for the following
1) Write a program to swap two integers using function template.
2) Write a program to display the contents of a text file in the reverse order.
3) Write a program to calculate area of a rectangle and a triangle using function
overloading.
4) Write a C++ program to calculate area and circumference of a circle using inline
function.
5) Design a base class person (name, address, phone-no). Derive a class employee (eno,
ename) from person. Derive a class manager (designation, department, basic-salary)
from employee. Accept all details of n managers and display manager having highest
salary.
6) Create a C++ class sumdata to perform the following functions:
int sum(int,int)- returns addition of two integer arguments.
float sum(float, float, float)- returns the addition of three float arguments.
7) Write a C++ program which will accept ‘n’ integers from user, write all even integers
into “even.dat” file and write all odd integers into “odd.dat” file. Display the contents
of both the files.
8) Write a program to overload == operator to compare two strings.
9) Write C++ program to accept item details(Imo, Iname, Iprice) of five items. Display
item name with the highest price. (Use array of objects)
10) Write a C++ program to calculate simple interest amount. Use default value for rate,
11) Write a C++ program to find area of triangle, circle and rectangle using function
overloading.
12) Design a class Student. Include data members rollno, name, city and age. Write
member functions:
i) To accept information of ‘n’ students
ii) To display information of ‘n’ students
iii) To search details of a student using rollno
(use array of objects)
13) Write a C++ program to create a class Worker with data members as worker-name,
no-of-hours-worked, pay-rate. Write necessary member functions to calculate and
display the salary of worker. Write necessary member functions to calculate and
display the salary of worker.(Use default value for pay-rate)
14) Write a C++ program to create a base class Increment. Write necessary member
functions to overload the operator unary pre and post increment ‘++’ for an integer
number.
15) Design a C++ class which contains functions display(). Write a program to count no.
Of times display() function is called.(Use static data member).
16) Write a C++ program to read “ABC.txt”. Write all even numbers in “even.txt” and
odd numbers in “odd.txt”. Display contents of both the files.
17) Design a base class Customer (name, phoneNo). Derive a class Depositor (accNo,
bal) from Customer. Again derive a class Borrower (loanNo, loan-amt) from
Depositor. Write necessary member functions to read and display the details of n
Customers.
18) Write a C++ program to swap two numbers by using function template.
19) Write a program to read contents from the file “sample.txt”. Store all the characters
from this file into the file in “character.txt” and all digits into the file “digit.txt”.
20) Define a C++ class Cstring to represent a string. Define parameterized constructor and
member function to display string . Overload unary to change the case of the string
object.
21) Design a base class Person (name, address) and derived class as Student(rollno,
percentage). Write member functions to accept and display information of
student.(use virtual function).
22) Write a C++ program to sort integer and float array elements in ascending order by
using function overloading
23) Design a base class staff (staffno, name, salary) and two derived classes as teaching
staff(subject) and nonteaching staff(post). Write necessary member function to accept
and display information of all staff members.
24) Write a C++ program to find out minimum and average of two integer numbers of
two different classes using friend function.
25) Create a class pair that contains two integer data members. Define appropriate
constructor to initialize a pair object, Define member functions:
i) To find maximum of a pair.
ii) To add integers of the pair.

You might also like