You are on page 1of 9

BCA SEM III OOP AND C++

QUESTION BANK of CS – 14 OOP and C++


1 MARKs QUESTIONs

1. C++ was originally developed by ____________________


A. Bjarne Stroustrup
2. List out any three features of Object Oriented Programming.
A. (i) Data hiding (ii) Inheritance (iii) Polymorphism
3. Which of the header file must be including for the input and output in C++?
A. <iostream.h>
4. Explain any three difference between C and C++.
A.
Sr. No. C C++
1 Developed by Dennis Ritchie Developed by Bjarne Stroustrup
2 C supports procedure oriented C++ supports both procedure and
programming paradigm for code object oriented programming
development. paradigm.
3 C used functions for input/output C++ uses objects for input/output
like printf( ) and scanf( ). like cin and cout.

5. Which symbol terminates or ends all the lines of C++ program?


A. ;
6. The wrapping the data and function into single unit is called ____________
A. Data Encapsulation.
7. Define the term data abstraction.
A. It is a mechanism to separate interface and implementation, means display only essential
information to outside the world and hide background detail.
8. ADT stands for ________________
A. Abstract Data Type
9. What is difference between Object and Class?
A. Object is an instance of class and class is a group of similar objects.
10. What are C++ tokens? List out them.
A. Tokens are smallest individual unit in C++ programs. C++ has the following tokens:
 Keyword
 Identifier
 Constants
 Strings
 Operators
11. Which operator is used to compare two operands?
A. = =
12. The operator >> is called ____________
A. Extraction Operator or Input operator
13. Scope resolution operator (::) is used to resolve ______________
A. Scope of a variable

Prepared by | Hemang R Chath


BCA SEM III OOP AND C++

14. The operator << is called ____________


A. Insertion operator or Output operator
15. What is public, private and protected in C++?
A. Access specifier to access members of class.
16. What will be the output of following program?
#include<iostream.h>
int man( )
{
int a;
a=5+3 *5 ;
cout << a ;
return 0 ;
}
A. 20
17. What will be the output of the following program?
#include<iostream.h>
int main( )
{
int a = 5 ;
a = 3 + 2 * a++ ;
cout << a ;
return 0 ;
}

A. 14
18. int max( void );
Identify above function type according to the prototype (declaration) of function.
A. return type with no argument
19. Consider the following code:
int a=10, b=20, c;
c = addition(a,b);
in above code identify the parameters passing techniques of function.
A. Call by value
20. What is polymorphism?
A. Polymorphism means that same code of operations or objects behave differently in different
instances.
21. Give an example of polymorphism.
A.
 Example: Suppose if you are in class room that time you behave like a student, when you are
in market at that time you behave like a customer, when you are at your home at that time you
behave like a son or daughter, here one person have different-different behaviours.
 So this is polymorphism in that same code of operations behaves differently in different
instances.

Prepared by | Hemang R Chath


BCA SEM III OOP AND C++

22. What is constructor?


A. Constructor is a special member function provided by C++ which is used to initialize an object
when object of particular class is created.
23. When a constructor is called?
A. Constructor is called when object of class is created.
24. What is copy constructor?
A. A copy constructor is a special constructor that can be called to copy an object
25. What is destructor? How many destructors can be declared in programming?
A. A destructor is special member function provided by the C++ that destroys the objects when
they are no longer required. We can take only one destructor in program.
26. How many arguments Destructor have?
A. 0 (or destructor have no arguments)
27. What is the default return type of destructor?
A. Destructor has no return type.
28. The directives for the pre-processors begin with _____
A. #
29. Function within a class is called?
A. Member function
30. How can we access private member function of the class?
A.
 Generally we declare member function in public section, but if we declare member function in
private section then we cannot call directly from the main( ).
 So, to access private member function, we have to declare a public function of that class and
we call this private function inside the public member function. So, a public member
functions are called by object from main( ).
31. What is the answer of x and y variable after execute below statement
x = 10; y = x++ ;
A. x= 11 and y = 10
32. A friend function can declare in public section only. True or false?
A. False
33. A friend function can be invoked with object of the class for which it is declared friend. True or
False?
A. False
34. Function overloading and operator overloading also know as ____________
A. Compile time polymorphism or Early binding
35. Which method is used to convert basic to class type conversation?
A. The conversion from basic type to class type can be performed by using only one argument
constructor write in a class and it is also called conversion constructor.
36. Which method is used to convert class type to basic conversion?
A. An overloaded casting operator convert class type to basic type conversion, it is also called
conversion function.
37. Which of the stream class contain the overloaded insertion operator?
A. ofstream class

Prepared by | Hemang R Chath


BCA SEM III OOP AND C++

38. A member declared as a protected is accessible by the member functions within its class
and ______________
A. It’s derived class
39. Which operators are used to allocate and de-allocate the memory run-time?
A. new operator is used to allocate memory and delete operator is used to de-allocate the memory
40. A static member function can be called using the class name. True or False?
A. True
41. When one class is derived from two or more class is called _________ inheritance.
A. Multiple Inheritance
42. What is hybrid inheritance?
A. A combination of hierarchical and multiple inheritances or a combination of two or more types
of inheritance is called hybrid inheritance.
43. What is the return type of destructor?
A. Destructor has no return type.
44. STL stands for __________________.
A. Standard Template Library
45. A file can be open with help of ______________ or _____________
A. Constructor or fopen( ) function
46. What is reference variable?
A. A reference provides an alias (alternative name) for a previously defined variable.
47. A template function cannot be overloaded. True or false?
A. False
48. The member of class in C++ is by default __________.
A. Private
49. How protected keyword is useful?
A. Protected keyword is useful for accessing members of base class in derived class.
50. In C++, the string literal “C++” occupies exactly _________ of memory.
A. 4 bytes
51. What is inheritance?
A. Creating a new class from the existing class is called inheritance.
52. What is the difference between get( ) and getline( ) function?
A. get( ) function is used to get a single character while getline( ) function get a line of string.
53. What is exception handling?
A. Exception handling is a mechanism provided by the C++ to handle run-time error.
54. What are the C++ stream classes?
A. C++ provides many classes that work with console and file operations. These classes are
called stream classes. i.e. ios, istream, ostream, iostream, etc are the C++ stream classes.
55. What are the modes of files used in file program?
A.
 In order to open a file with a stream object open( ) function is used.
 Syntax: open (filename, mode) ;
 Where file name is sequence of characters that represents the file name to be opened and
mode is an optional parameter with a combination of the following flags:
ios :: ate ios :: app ios :: in ios :: out ios :: trunc, etc.

Prepared by | Hemang R Chath


BCA SEM III OOP AND C++

56. Which classes are used to create input stream and output stream of file in C++?
A. ifstream class and ofstream class

57. What is the difference between width( ) and setw( )?


A. width( ) is formatted output function and setw( ) is a manipulator in C++.
58. Which header file is need to be included to perform file handling in C++
A. <fstream.h>
59. Run-time polymorphism is also known by the term _______________.
A. Late binding
60. Only one copy of the class is inherited when it is defined as _________ class
A. virtual
61. To achieve Exception handling which keywords are used?
A. try, catch and throw
62. What is this pointer?
A. This pointer is point to the object itself and find out the address of object.
63. What would be the output of the following code?

cout.fill('*') ;
cout.setf ( ios : : left, ios : : adjustfield) ;

cout.width(20):
cout << "I/O Operations";

A. I/O Operations******
64. ifstream and ofstream classes are derived from _________ class
A. fstream base class
65. Write down the syntax to create generic type using template.
A. template <class generic_type>
66. Run-time polymorphism is achieved by _______ function.
A. Virtual
67. A pure virtual function can never have a body. True or False?
A. True
68. RTTI stands for _________________.
A. Run Time Type Identification
69. Early binding is also known by the term ___________________.
A. Compile time polymorphism
70. resetiosflags() manipulator is equivalent to which ios function?
A. unsetf ( ) function

Prepared by | Hemang R Chath


BCA SEM III OOP AND C++

2 MARKs QUESTIONs

Briefly discuss following

1. Polymorphism
2. Encapsulation
3. Inheritance
4. Abstraction
5. Extraction operator
6. Insertion operator
7. Cascading of I/O operators
8. Dynamic initialization of variable
9. Reference variable
10. Scope resolution operator
11. Member dereferencing operator
12. New
13. Delete
14. Const arguments
15. Class
16. Object
17. Private
18. Public
19. Object as function argument
20. Returning object from function
21. Pointer to object
22. Pointer to data member
23. Default constructor
24. Copy constructor
25. Parameterized constructor
26. Destructor
27. List out operators which cannot be overloaded
28. List out types of inheritance available in C++
29. Protected
30. Virtual Base Class (Only definition)
31. Abstract Class
32. this pointer
33. put()
34. get()
35. width()
36. precision()
37. fill()
38. unsetf()
39. setw()
40. setprecision()

Prepared by | Hemang R Chath


BCA SEM III OOP AND C++

41. setfill()
42. resetiosflags()
43. ios::adjustfield
44. ios::floatfield
45. ios::basefield
46. ios::showbase
47. ios::showpos
48. ios::showpoint
49. ios::uppercase
50. seekg and seekp
51. tellg and tellp
52. eof()
53. fail()
54. bad()
55. good()
56. Define template (only definition)
57. Exception (definition)
58. try
59. catch
60. throw

3 MARKs QUESTIONs

Write a short note on


1. POP
2. OOP
3. Data Abstraction and Encapsulation
4. Polymorphism
5. Applications of OOP
6. cin and cout
7. Structure of C++ program
8. Reference variable
9. Function prototyping
10. Call by reference
11. Return by reference
12. Inline function
13. Default arguments
14. Data members and member functions
15. Declaring member function outside class
16. Static data members
17. Constructors (Definition and List of constructors)
18. Rules for operator overloading
19. Type conversion: basic->class

Prepared by | Hemang R Chath


BCA SEM III OOP AND C++

20. Single inheritance


21. Multiple inheritance
22. Multilevel inheritance
23. Hierarchical inheritance
24. Concept of virtual base class (without program)
25. Nesting of classes
26. Pointer to function (without progr am)
27. this pointer
28. Pointers to derived class (without program)
29. Concept of virtual function (without program)
30. C++ Streams
31. C++ Stream classes
32. Setf() function
33. Manipulators (Theory only)
34. Program to create user-defined manipulator
35. Classes for file stream operations
36. File opening modes (without program)
37. File pointers (without program)
38. put() and get() functions (without program)
39. write() and read() functions (without program)
40. Class Template / Generic Programming / Class with parameters (without program)
41. Function Template (Without Program)
42. Write a program to illustrate function template
43. Exception
44. Basics of Exception Handling
45. Write a program to illustrate exception handling

5 MARKs QUESTIONs

1. Write a note on OOP and its advantages over POP


2. Discuss OOP Paradigm (Concepts of OOP)
3. Write a C++ program to explain insertion and extraction operators
4. Explain use of reference variable with suitable example
5. Explain Scope Resolution operator with suitable example
6. Explain New and Delete with appropriate example
7. Write a program to illustrate default arguments
8. Can we define member functions outside the class? Justify.
9. Write a note on memory allocation for class objects
10. Write a note on friend function with suitable example
11. Write a program to illustrate pointer to object and pointer to data member
12. Explain different types of constructors with suitable example
13. What is use of copy constructor? Explain with suitable example
14. Write a note on operator overloading.
15. Write a program to overload any unary operator

Prepared by | Hemang R Chath


BCA SEM III OOP AND C++

16. Write a program to overload any binary operator


17. Write a program to overload an operator with friend function
18. Write a program to overload a binary operator for strings
19. Write a note on type conversion
20. Write a program to convert class data type to basic
21. Write a program to convert one class type to another
22. Write a note on inheritance with suitable program
23. Discuss hybrid/Multipath inheritance with appropriate example
24. Write a note on virtual base class
25. Write a program to illustrate constructors in derived class
26. Write a note on pointer to function with suitable example
27. Explain virtual function with suitable example
28. Discuss rules for virtual functions
29. Discuss I/O operations with stream classes
30. Write a program to illustrate following functions
a. width()
b. fill()
31. Write a detailed note on setf() and its parameters
32. Explain manipulators with suitable example
33. Write a program to count number of characters, digits, spaces, lines and words from a file.
34. Write a program to copy content of one file to another with help of command line
35. Write a program to write objects of class into a file and then read them back
36. Write a program to illustrate use of file pointer, seekg, seekp, tellg and tellp
37. Write a detailed note on class template with suitable example
38. Write a detailed note on function template with suitable example
39. Write a note on Exception Handling
40. Write a program to illustrate use of try, catch and throw

Prepared by | Hemang R Chath

You might also like