Professional Documents
Culture Documents
aspx
a. ios::cur
b. ios::set
c. ios::end
d. ios::beg
2) During dynamic memory allocation in CPP, new operator returns _________ value if
memory allocation is unsuccessful.
a. False
b. NULL
c. Zero
d. None of these
3) We can create objects of the abstract class.
a. True
b. False
4) Which of the followings is/are pointer-to-member declarator?
a. ->*
b. .*
c. ::*
d. both a and b
5) Default value of static variable is_____ .
a. 0
b. 1
c. Garbage value
d. Compiler dependent
6) ________ are used to format the data display in CPP.
a. Iterators
b. Punctuators
c. Manipulators
d. Allocators
7) Reusability of the code can be achieved in CPP through ______ .
pg. 1
a. Polymorphism
b. Encapsulation
c. Inheritance
d. Both a and c
8) By default, members of the class are ____________ in nature.
a. protected
b. private
c. public
d. static
10) Which of the following is CPP style type-casting?
a. per = total/(float)m
b. per = total/float(m)
c. per = (float)total/m
d. None of these
11) If a program uses Inline Function, then the function is expanded inline at
___________.
a. Compile time
b. Run time
c. Both a and b
d. None of these
12) In CPP, the size of the character array should be one larger than the number of
characters in the string.
a. True
b. False
13) Which of the following is/are valid ways to allocate memory for an integer by dynamic
memory allocation in CPP?
a. +=, ?, :: , >>
b. >>, <<, ?, *, sizeof()
pg. 2
c. :: , . , .* , ?:
d. :: , ->, * , new, delete
15) Static variable in a class is initialized when _____ .
a. < ifstream>
b. < ofstream>
c. < fstream>
d. Any of these
17) An exception is thrown using _____________ keyword in CPP.
a. throws
b. throw
c. threw
d. Thrown
18) Which of the followings is/are not a manipulator/s ?
1. flush
2. base
3. ends
4. oct
5. bin
6. skipws
a. Only 1, 6
b. Only 1,4,6
c. Only 1,3,6
d. Only 2,5
19) If default constructor is not defined, then how the objects of the class will be created?
pg. 3
a. Yes
b. No
21) Members of the class can be declared with auto, extern or register storage classes.
a. True
b. False
22) C structure differs from CPP class in regards that by default all the members of the
structure are __________ in nature.
a. private
b. protected
c. public
d. None of these
23) Which of the following best defines the syntax for template function ?
a. Template
b. Template return_type Function_Name(Parameters)
c. Both a and b
d. None of these
24) Generic pointers can be declared with__________ .
a. auto
b. void
c. asm
d. None of these
25) Which of the followings are true about constructors?
a. Only 1,2,4
b. 1,2,4,5
c. 1,3,5
d. 1,4,5
pg. 4
TEST 2:
1) Which of the following are true about static member function?
a. Only 2
b. Only 2,5
c. Only 2,3,4,5
d. Only 2 , 3 , 5
e. All of these
2) Static variable must be declared in public section of the class.
a. True
b. False
3) By default, if a function with minimum lines of code is declared and defined inside the
class becomes Inline function.
a. True
b. False
4) class X, class Y and class Z are derived from class BASE. This is ______ inheritance.
a. Multiple
b. Multilevel
c. Hierarchical
d. Single
5) When base class is derived in protected mode, then_____________ .
pg. 5
a. Only 1, 5
b. Only 1, 6
c. Only 2, 6
d. Only 2, 4
6) Can we have overloading of the function templates?
a. Yes
b. No
7) Streams that will be performing both input and output operations must be declared as
class _________ .
a. iostream
b. fstream
c. stdstream
d. Stdiostream
8) Exception handlers are declared with ____________ keyword.
a. Try
b. catch
c. throw
d. Finally
9) Which of the following statements are true about Catch handler?
a. Only 1, 4, 5
b. Only 1, 2, 3
c. Only 1, 4
d. Only 1, 2
10) Static variable declared in a class are also called_________ .
a. instance variable
b. named constant
c. global variable
d. class variable
11) Which of the following operator is used to release the dynamically allocated memory
in CPP?
pg. 6
a. remove
b. free
c. delete
d. both b and c
12) Which of the following is not a false statement about new operator?
a. It can’t be overloaded.
b. It returns garbage value when memory allocation fails.
c. It automatically computes the size of the data object.
d. All of these
13) Private members of the class are accessible only to the members of the same class.
a. True
b. False
14) Run time polymorphism can be achieved with______ .
a. ofstream
b. ifstream
c. iostream
d. None of these
16) Catch handler can have multiple parameters.
a. True
b. False
17) Inline functions may not work ______ .
a. Only 1,4,5
b. Only 2,3,5
c. Only 1,3,4
d. All of these
pg. 7
18) Which of the followings is/are not false about friend function ?
a. Only 2,4
b. Only 1,2,5
c. Only 2,3,5
d. All of these
19) Predict the output:
int x = 786;
cout << setfill(‘*’) << setw(6) << x;
a. 786***
b. **786
c. ***786
d. ******
20) Default return type of functions in CPP is ____ .
a. void
b. long
c. char
d. Int
21) Default values for a function are need to be specified from left to right only.
a. True
b. False
22) During a class inheritance in CPP, if the visibility mode or mode of derivation is not
provided, then by default visibility mode is ___________.
a. public
b. protected
c. private
d. Friend
23) The derivation of Child class from Base class is indicated by ____ symbol.
pg. 8
a. ::
b. :
c. ;
d. |
24) If we have object from fstream class, then what is the default mode of opening the file?
a. ios::in|ios::out
b. ios::in|ios::out|ios::trunc
c. ios::in|ios::trunc
d. Default mode depends on compiler
25) __________ is return type of is_open() function.
a. int
b. bool
c. float
d. char *
TEST3:
1) Public data members and member functions of the class are accessible ONLY to the
member functions of that class.
a. True
b. False
2) Only functions of the class can access the data of the class and they(functions) provides
the interface between data, objects and the program. This kind isolation of the data from
direct access by the program is called _______________ .
a. Data Abstraction
b. Data Hiding
c. Data Binding
d. Data Encapsulation
3) A Constructor that does not have any parameters is called____________ Constructor.
a. Custom
b. Dynamic
c. Static
d. Default
4) If we have object from ofstream class, then default mode of opening the file is _____ .
pg. 9
a. ios::in
b. ios::out
c. ios::in|ios::trunc
d. ios::out|ios::trunk
5) _______________ is a member function that is declared within a base class and
redefined by derived class.
a. virtual function
b. static function
c. friend function
d. const member function
6) Syntax for Pure Virtual Function is ______________ .
a. explicit
b. garbage
c. bool
d. static
8) We can initialize a value of static variable of a class only when its object is created. No
other initialization is permitted.
a. True
b. False
9) When a base class is privately inherited by the derived class, then_____________ .
a. protected members of the base class become private members of derived class
b. public members of the base class become private members of derived class
c. both a and b
d. only b
10) What is the difference between protected and private access specifiers in inheritance?
pg. 10
a. True
b. False
12) In nested try blocks, if both inner and outer catch handlers are not able to handle the
exception, then ______________ .
a. stop()
b. aborted()
c. terminate()
d. Abandon()
14) In CPP, it is mandatory and must to initialize const variables.
a. True
b. False
15) When a class is defined inside any function or block, it is called ___________ .
a. Nested class
b. Block class
c. Local class
d. It is not possible
16) Which of the followings are false statements about Local class?
1. A local class type name can only be used in the enclosing function
2. All the methods of Local classes must be defined inside the class only
3. A Local class can contain static data members.
4. A Local class may contain static functions.
5. Non-static variables of the enclosing function are not accessible inside local classes.
6. Local classes cannot access global types, variables and functions.
a. Only 1,3
b. Only 3, 6
c. Only 2 , 4 , 6
d. None of these
17) Due to ios::trunc mode, the file is truncated to zero length.
pg. 11
a. True
b. False
18) A const object of a class can call non-const member function of the class.
a. True
b. False
19) If an argument to a function is declared as const, then _______ .
a. int
b. bool
c. char *
d. double
21) Can we write throw clause inside catch handler?
a. Yes
b. No
22) Default values for a function are specified when ____ .
a. function is defined
b. function is declared
c. Both a and b
d. None of these
23) Can member functions of one class be friend functions of another class?
a. Yes
b. No
24) Predict the output:
float x= 3.1496;
cout << setpricision(2) << x;
a. 3.14
b. 3.15
pg. 12
c. 3.00
d. None of these
25) In case of binary operator overloading with member function, which of following
statement should be taken into consideration?
TESt4:
1) Can constructors be overloaded?
a. Yes
b. No
2) Assume class TEST. Which of the following statements is/are responsible to invoke
copy constructor?
a. TEST T2(T1)
b. TEST T4 = T1
c. T2 = T1
d. both a and b
e. All of these
3) When overloading unary operators using Friend function,it requires_____ argument/s.
a. Zero
b. One
c. Two
d. None of these.
4) In CPP program, Can we declare and define a user defined function inside a struct as
we do in a class ?
a. Yes
b. No
c. Can’t say
5) ____________ refers to the act of representing only essential features without including
the background details.
a. Data Hiding
b. Data Encapsulation
pg. 13
c. Data Abstraction
d. All of these
6) Runtime polymorphism is achieved only when a virtual function is accessed through a
pointer to the base class.
a. True
b. False
7) Find the wrong statement/s about Abstract Class.
a. Function Overriding
b. Function Overloading
c. Both a and b
d. None of the above
9) Function overloading can also be achieved if two or more functions differ only in their
return types.
a. True
b. False
10) In nested try block, if inner catch handler gets executed, then _____________ .
a. True
b. False
12) Which of the following statements are not true about destructor?
pg. 14
4. It can be declared in private section
5. It bears same name as that of the class and precedes Lambda sign.
a. Only 2, 3, 5
b. Only 2, 3, 4
c. Only 2, 4, 5
d. Only 3, 4, 5
13) When a child class inherits traits from more than one parent class, this type of
inheritance is called _______________ inheritance.
a. Hierarchical
b. Hybrid
c. Multilevel
d. Multiple
14) In case of inheritance where both base and derived class are having constructor and
destructor, then which if the following are true ?
a. Only 2 ,4
b. Only 1 , 3
c. Only 1 , 4
d. Only 2, 3
15) __________________ is the OOP feature and mechanism that binds together code and
the data it manipulates, and keep both safe from outside world.
a. Data Binding
b. Data Encapsulation
c. Data Storing
d. Data Abstraction
16) Which of the followings is/are not keyword/s in CPP?
1. asm
2. boolean
3. mutable
4. export
5. constant_cast
a. Only 5
b. Only 1 and 4
pg. 15
c. Only 1,2 and 5
d. Only 2 and 5
17) We can create objects of the abstract class.
a. True
b. False
18) Which of the followings are true about Virtual functions?
a. True
b. False
20) Which of the following are member dereferencing operators in CPP?
1. *
2. ::
3. ->*
4. ::*
5. ->
a. Only 1, 3, 4
b. Only 1 and 5
c. Only 3 and 4
d. Only 3,4,5
21) In Multipath inheritance, in order to remove duplicate set of records in child class, we
___________ .
a. Optional
b. Mandatory
pg. 16
c. Compiler dependent
d. Error
23) Using friend operator function, following perfect set of operators may not be
overloaded.
a. = , ( ) , [ ] , ->
b. <<, = = , [ ] , >>
c. ?, = , ( ) , ++
d. None of these
24) An operator function is created using _____________ keyword.
a. iterator
b. allocator
c. constructor
d. operator
25) Classes in CPP are________ .
TEST4:
1) Can we define our exceptions in CPP?
a. Yes
b. No
2) The code of statements which may cause abnormal termination of the program should
be written under_________ block.
a. Try
b. catch
c. Finally
d. None of these
3) Object based language differs from object oriented language as it does not support
features _____ .
1. Encapsulation
2. Inheritance
3. Dynamic Binding
pg. 17
4. Abstraction
5. Polymorphism
a. only 3 ,4
b. only 1,3,5
c. 2,4,5
d. Only 2,3
4) When a virtual function is redefined by the derived class, it is called___________.
a. Overloading
b. Overriding
c. Rewriting
d. All of these
5) In any ways, Non-member function cannot have access to the private data of the class.
a. True
b. False
6) In CPP, dynamic memory allocation is done using ______________ operator.
a. calloc()
b. malloc()
c. allocate
d. New
7) Can we allocate memory for the objects dynamically in CPP?
a. Yes
b. No
8) If the derived class is struct, then default visibility mode is _______ .
a. public
b. protected
c. private
d. struct can’t inherit class
9) Which of the following manipulator is used for the representing octal equivalent of a
given decimal number?
a. oct
b. setbase(8)
c. tobase(8)
d. both a and b
e. all a, b, c
pg. 18
10) Which of the following is not a casting operator in CPP?
a. explicit_cast
b. static_cast
c. dynamic_cast
d. reinterpret_cast
11) ___________ header file is used for manipulators.
a. < iomanipulator.h>
b. < stdiomanip.h>
c. < stdmanip.h>
d. < iomanip.h>
12) While redefining a virtual function in the derived class, if its prototype is changed then
___________________ .
a. True
b. False
14) In a program, If there exists a function template with two parameters and normal
function say void add(int , int), so add(3,4) will _____________________ .
a. Yes
b. No
16) In case of inheritance where both base and derived class are having constructors,
when an object of derived class is created then___________ .
pg. 19
17) Which of the following is not a file opening mode ____ .
a. ios::ate
b. ios::nocreate
c. ios::noreplace
d. ios::truncate
18) Attempting to throw an exception that is not supported by a function call results in
calling _____________ library function.
a. indeterminate()
b. unutilized()
c. unexpected()
d. unpredicted()
19) How can we restrict a function to throw certain exceptions?
a. Yes
b. No
21) The purpose of explicit keyword is to tell the compiler that a certain constructor may
not be used to implicitly cast an expression to its class type.
a. True
b. False
22) Scope resolution operator is used______ .
a. Only 2
b. Only 1, 3
pg. 20
c. Only 2 , 3
d. All 1 , 2, 3
24) A try block can be nested under another try block.
a. True
b. False
25) In nested try blocks, there is no need to specify catch handler for inner try block.
Outer catch handler is sufficient for the program.
a. True
b. False
TEST5:
1) We can prevent a function from throwing any exceptions.
a. True
b. False
2) Functions called from within a try block may also throw exception.
a. True
b. False
3) The explicit keyword is an optional decoration for the constructors that takes
exactly_____argument.
a. No argument
b. Two
c. Three
d. One
4) A class can contain objects of other classes and this phenomenon is called_________ .
a. Relationship
b. Object Association
c. Containership
d. None of these
5) Can we alter/modify the values of data members of a class inside const member
function?
a. Yes
b. No
pg. 21
6) If a class contains pure virtual function, then it is termed as____________________ .
a. Virtual class
b. Sealed class
c. Pure Local class
d. Abstract Class
7) If inner catch handler is not able to handle the exception then__________ .
a. catch(..,)
b. catch(---)
c. catch(…)
d. catch( void x)
9) Which one is suitable syntax for function template?
a. True
b. False
11) Private members of the class are not inheritable.
a. True
b. False
12) While overloading binary operators using member function, it requires ___
argument/s.
a. Zero
b. One
c. Two
d. Three
13) If abstract class is inherited by derived class, then_______________ .
pg. 22
a. Derived class should provide definition for all the pure virtual functions
b. Derived class also become abstract if fails to implement pure virtual functions
c. Objects of derived class can’t be created if it fails to implement pure virtual functions
d. All of these
14) By default, all the files are opened in ___________mode .
a. Binary
b. Text
c. Can’t say
15) Generic catch handler must be placed at the end of all the catch handlers.
a. True
b. False
16) An exception can be of only built-In type.
a. True
b. False
17) The CPP compiler supports automatic type conversions for the user defined
datatypes.
a. True
b. False
18) Can a class be declared/defined inside another class ?
a. Yes
b. No
19) Can we pass parameters to base class constructor though derived class or derived
class constructor?
a. Yes
b. No
20) _________________are used for generic programming.
a. Inheritance
b. Virtual Functions
c. Templates
d. None of these
21) Irrespective of exception occurrence, catch handler will always get executed.
a. True
b. False
pg. 23
22) In CPP, cin and cout are the predefined stream __________ .
a. Operator
b. Functions
c. Objects
d. Data types
23) Object oriented programming employs_________ programming approach.
a. top-down
b. procedural
c. bottom-up
d. all of these.
24) Constant variables can be created in CPP by using ________ .
a. enum
b. const
c. #define
d. All of these
e. None of these
25) A virtual function that has no definition within the base class is called____________.
pg. 24