9111128, 10:28 PM 300 C++ Programming Multiple Choice Questions and Answers
Interview Questions | Mcas
Aner GET Cane
wi
Yor
$41
W 136th St, New York Trinity Hall, Leeds W 112th St, New York
ee
Home » C++ Programming Questions » 300 C++ Programming £17e
Multiple Choice Questions and Answers
300 C++ Programming Multiple Jun
ies
Choice Questions and Answers 12
New
See what Ne
‘$74
Rent Uni Homes
AmberStudent
YouTube Shorts
hnps:[Link]-programming-mulipl-choice-questions-and-answers! 128‘911123, 1028 PM 300 G++ Programming Mutiple Choice Questions ané Answers
C++ Programming Multiple Choice Questions |
MCQs of c++ Exam
1, If the class name is X, what is the type of its “this” pointer
(Gin a nonstatic, non-const member function)?
a. const X* const
b. X* const
c.X*
d.X&
2. Which classes allow primitive types to be accessed as
objects?
a. Storage
b. Virtual
c. Friend
4. Wrapper
3. When is std::bad_alloc exception thrown?
a, When new operator cannot allocate memory
b. When alloc function fails
c. When type requested for new operation is considered bad,
thisexception is thrown
d. When delete operator cannot delete the allocated
(corrupted) object
htps:[Link]/c-programvming-muliple-choice-questions-and-answers!
2106‘911128, 1028 PM 300 C++ Programming Multiple Choice Questions and Answers
W 136th St, New York Trinity Hall, Leeds W 112th St, New York Bernard Brooklyn Hon
$1150 e175 $1,550 Br
$890
4. Which one of the following is not a fundamental data
type in C++
a. float
b. string
c. int
d. wehar_t
5. Which of the following is a valid destructor of the class
name “Country”
a. int ~Country0)
b. void CountryQ)
. int ~Country(Country obj)
d. void ~Country
6. Which of the following correctly describes C++ language?
a. Statically typed language
b. Dynamically typed language Q
htps:[Link]-programvming-muliple-choice-questions-and-answers! 3126‘911128, 1028 PM 300 C++ Programming Multiple Choice Questions and Answers
c. Both Statically and dynamically typed language
d. Type-less language
7. Which of the following keyword supports dynamic
method resolution?
a. abstract
b. Virtual
c. Dynamic
d. Typeid
8. Which of the following is the most preferred way of
throwing and handling exceptions?
a. Throw by value and catch by reference.
b. Throw by reference and catch by reference.
c. Throw by value and catch by value
d. Throw the pointer value and provide catch for the pointer type.
9. Which of the following is not true about preprocessor
directives
a. They begin with a hash symbol
b. They are processed by a preprocessor
c. They form an integral part of the code
d. They have to end with a semi colon
10. What’s wrong? while( (i < 10) && (i > 24))
htps:[Link]/c-programvming-muliple-choice-questions-and-answers!
4128‘911128, 1028 PM 300 C++ Programming Multiple Choice Questions and Answers
a. the logical operator && cannot be used in a test condition
b. the while loop is an exit-condition loop
c. the test condition is always false
d. the test condition is always true
C++ MCQs
11. A continue statement causes execution to skip to
a, the return 0; statement
. the first statement after the loop
c. the statement following the continue statement
d. the next iteration of the loop
12. What’s wrong? (x = 4 && y = 5) ? (a= 5) (b = 6);
a. the question mark should be an equal sign
b. the first semicolon should be a colon
c. there are too many variables in the statement
d, the condi
nal operator is only used with apstrings
13. What's wrong? for (int k = 2, k <=12, k++)
htps:[Link]/c-programvming-muliple-choice-questions-and-answers!
826‘911128, 1028 PM 300 C++ Programming Multiple Choice Questions and Answers
a. the increment should always be ++k
b. the variable must always be the letter i when using a for
loop
c. there should be a semicolon at the end of the statement
d. the commas should be semicolons
14. Which of the following is not recommended in a header
file?
a. Type definitions (typedef)
b. Class definitions
c. Function definitions
d. Template definitions
15. Which of the STL containers store the elements
contiguously (in adjacent memory locations)?
a. std::vector
b. std:
c. std::map
d. std::set
16. Which of the following is not a standard exception built
in C++.
a, std::bad_creat
b. std::bad_alloc
htps:[Link]/c-programvming-muliple-choice-questions-and-answers!
626‘911128, 1028 PM 300 C++ Programming Multiple Choice Questions and Answers
c. std::bad_cast
dst
ad_typeid
17. What does STL stand for?
a. Simple Template Library
b. Standard Template Library
¢. Static Type Library
d. Single Type-based Library
18. What is the difference between overloaded functions
and overridden functions?
a. Overloading is a dynamic or run-time binding and Overriding is
static or compil
ime binding
W 136th St, New York Trinity Hall, Leeds W 112th St, New York
$1350 e175 $1550
b. Redefining a function in a friend class is called function
overriding while Redefining a function in a derived class is
called an overloaded function.
c. Overloading is a static or compile-time binding and Overriding is
dynamic or run-time binding
htps:[Link]/c-programvming-muliple-choice-questions-and-answers!
Bernard Brooklyn Hon
Br
$890
7126‘9111128, 1028 PM 300 C++ Programming Multiple Choice Questions and Answers
d. Redefining a function in a friend class is called function overloading
while Redefining a function in a derived class is called as overridden
function.
19. Which one of the following is not a valid reserved
keyword in C++
a. Explicit
b. Public
c. Implicit
d. Private
20. Each pass through a loop is called a/an
a. enumeration
b. iteration
¢. culmination
a. pass through
21. Which of the following is true about const member
functions?
a. const members can be invoked on both const as well as nonconst
objects
b. const members can be invoked only on const objects and
not on nonconst objects
c. nonconst members can be invoked on const objects as well as.
nonconst objects
d. none of the above
22. Which of the following relationship is known as
inheritancerelationship?
a. ‘has-a’ relationship
htps:[Link]-programming-muliple-choice-questions-and-answers!
2126‘911128, 1028 PM 300 C++ Programming Multiple Choice Questions and Answers
b. ‘is-a’ relationship
c. association relationship
d. none of the above
W 136th St, New York
$1150
W 112th St, New York
$1550
23. If class A is friend of class B and if class B is friend of
class C, which of the following is true?
a. Class Cis friend of class A
b. Class A is friend of class C
c. Class A and Class C do not have any friend relationship
d. None of the above
24. A direct access file is:
a. A file in which recoreds are arranged in a way they are inserted in a
file
b. A file in which records are arranged in a particular order
c. Files which are stored on a direct access storage medium
d. None of the above
25. Which of the following is not a component of file system
a. Access method
b. Auxiliary storage management
Free integrity mechanism
d. None of the above
26. Seek time is
a. time taken to retrieve a dta
b. Time taken by read/write head mechanism to position itself over
htps:[Link]-programming-muliple-choice-questions-and-answers!
Bernard Brooklyn Hon
Br
$890
9126izs, 1028 PM 20 C++ Programming Multiple Choice Questions and Answers
appropriate cylinder
c. Time taken by appropriate sector to come under read/write
d. None of the above
27. ‘Prime area’ in context of file system is defined as
a. It is memory area created by operating system
b. It is an area into which data records are written
c. Itis the main area of a web page
d. None of the above
28. In mulit-list organization
a. Records that have equivalent value for a given secondary index item
are linked together to form a list.
b. Records are loaded in ordered sequence defined by
collating sequence by content of the key
c. Records are directly accessed by record key field
d. None of the above
29. Which of the following is/are advantages of cellular
partitioned structure:
a. Simultaneous read operations can be overlapped
b. Search time is reduced
c. Botha &b
d. None of the above
W 136th St, New York Hall, Leeds W 112th St, New York Bernard Brooklyn Hon
$1,150 $1,550 Br
$290
30. *ptr++ is equivalenet to: &
a. ptr++
[Link]-programvming-muliple-choice-questions-and-answers! 1026911123, 1028 Pat 300 C++ Programming Multiple Croice Questions ang Answers
b. *ptr
ce. ++*ptr
d. None of the above
31. The conditional compilation
a. It is taken care of by the compiler
b. It is setting the compiler option conditionally
c. It is compiling a program based on a condition
d. none of above
32. Originally ‘C’ was developed as:
a. System programming language
b. General purpose language
c. Data processing language
d. None of above
33- An inverted file
a. Locates information about data in small files that are maintained
apart from actual data record
b. A file which stores opposite records
c. A file which stores information about records of a system
d. None of above
34. Which of the following is not a file operation:
a. Repositioning
b. Truncating,
c. Appending
d. None of above
35. Latency time is:
a. Time taken by read/write head mechanism to position itself over
appropriate cylinder
b. ‘Time taken to transfer a dta from memory
c. Time taken by appropriate sector to come under read/write head
d. None of above
36. The two types of file structure existing in VSAM file are
a. Key sequenced structure, entry sequenced structure
htps:[Link]/c-programvming-muliple-choice-questions-and-answers!
26‘911123, 1028 PM 300 G++ Programming Mutiple Choice Questions ané Answers
b. Key sequence structure, exit sequenced structure
c. Entry sequence structure, exit sequenced structure
d. None of above
W 136th St, New York W 112th St, New York Bernard Brooklyn Hon
$1,150 $1,550 Br
$890
37. How many copies of a class static member are shared
between objects of the class?
a. A copy of the static member is shared by all objects of a class
b. A copy is created only when at least one object is created from that
class
c. A copy of the static member is created for each
instntiation of the class
d. No memory is allocated for static members of a class,
38. Which looping process checks the test condition at the
end of the loop?
a. for
b. while
c. do-while
d. no looping process checks the test condition at the end
39. The default access level assigned to members of a class
is
a. Private
b. Public
c. Protected
d. Needs to be assigned Ly
htps:[Link]/c-programvming-muliple-choice-questions-and-answers! 10126izs, 1028 PM 20 C++ Programming Multiple Choice Questions and Answers
40. Which of the following correctly describes the meaning
ofnamespace’ feature in C++?
a. Namespaces refer to the memory space allocated for
names used in a program
b. Namespaces refer to space between the names in a program
c. Namespaces refer to packing structure of classes in a program.
d. Namespaces provide facilities for organizing the names in aprogram
to avoid name clashes.
41. Which of the following correctly describes the meaning
of ‘namespace’ feature in C++?
a. Namespaces refer to the memory space allocated for names used in
a program
b. Namespaces refer to space between teh names in a program
Namespaces refer to space between the names in a program
d. namespaces provide facilities for organizing the names
in a program to avoid name clashes
42. Which of the following language is not supported by
C+4?
a. Exception Handling
b. Reflection
c. Operator Overloading
d. Namespaces
43. class derived: public base1, public basez { } is an
example of
a. Polymorphic inheritance
b. Multilevel inheritance
¢. Hierarchical inheritance
d. Multiple inheritance
44. Which of the following languages is a subset of C++
language?
a. Clanguage
b. Java Language
c. C# language
d. language
htps:[Link]/c-programvming-muliple-choice-questions-and-answers!
19126izs, 1028 PM 20 C++ Programming Multiple Choice Questions and Answers
45. How do we declare an ‘interface’ class?
a. By making all the methods pure virtual in a class
b. By making all the methods abstract using the keyword ‘abstract’ ina
class
c. By declaring the class as interface with the keyword ‘interface’
d. It is not possible to create interface class in C++
46. How do we declare an abstract class?
a. By providing at least one pure virtual method (function
signature followed by ==0;) in a class
b. By declaring at least one method abstract using the keyword
‘abstract’ in a class
c. By declaring the class abstract with the keyword ‘abstract’
d. It is not possible to create abstract classes in C++
47. Which of the following is not an advantage of secondary
memory
a. Itis cost-effective
b. Ithas large storage capacity
c. Ithas highest speed
. It is easily portable
48. What happens when a pointer is deleted twice?
a. It can abort the program
b. It can cause a failure
¢. It can cause an error
d. It can cause a trap
49. Which of the following language feature is not an access
specifier in C++?
a. public
b. private
c. C protected
d. internal
50. Expression C=i++ causes
a. Value of i assigned to C and then i incremented by 1
b. ito be incremented by 1 and then value of i assigned to C
htps:[Link]/c-programvming-muliple-choice-questions-and-answers!
ai26vas, 1028 PM 400 C++ Programming Mule Groce Questions an Answers
c. Value of i assigned to C
d. i to be incremented by 1
C++ Programming Objective Questions
51. The statement i++; is equivalent to
aizitis
bisita
ci
di-;
52. In C language, a hexadecimal number is represented by
dh
53- Which of the following library function below by default
aborts the program?
a. Terminate()
b. endO
c. Abort()
d. exit
54. Ifa member needs to have unique value for all the
objects of that same class, declare the member as
a. Global variable outside class
ide constructor
b. Local variable it
c. Static variable inside class
d. Dynamic variable inside class
55. Value of ix+j, if ij are integer type and ix long type
would be
a. integer
b. float
c. long integer
d. double percision
htps:[Link]/c-programvming-muliple-choice-questions-and-answers!
1926izs, 1028 PM 20 C++ Programming Multiple Choice Questions and Answers
56. Which of the following below can perform conversions
between pointers to related classes?
a. cast_static
b. dynamic_cast
c. static_cast
dc
dynamic
57. How do we define a constructor?
ax {}
[Link] O~
©. XO ~{}
d.~x0 0
58. Vtables
a. creates a static table per class
b. creates a static table per object
c. creates a dynamic table per class
d. creates a dynamic table per object
59. When class B is inherited from class A, what is the order
in which the constructers of those classes are called
a. Class A first Class B next
b. Class B first Class A next
c. Class B’s only as it is the child class
d. Class A’s only as it is the parent class
60. Which of the following is the most general exception
handler that catches exception of any type?
a. catch(std::exception)
b. catch(std::any_exception)
c. cateh(...)
d. catchO.
61. Which of the following is the most general exception
handler that catches exception of ‘any type’?
a. catch(std::exception)
b. catch(std::any_exception)
htps:[Link]/c-programvming-muliple-choice-questions-and-answers!
16026971123, 1028 Pat 300 C++ Programming Multiple Croice Questions ang Answers
¢. catchy
d. catchO.
62, In a group of nested loops, which loop is executed the
most number of times?
a, the outermost loop
b. the innermost loop
c. all loops are executed the same number of times
d. cannot be determined without knowing the size of the loops
63. What is the Difference between struct and class in terms
of Access Modifier?
a. By default all the struct members are private while by default class
members are public.
b. By default all the struct members are protected while by
default class members are private.
c. By default all the struct members are public while by default class
members are private.
d. By default all the struct members are public while by default class
members are protected.
64. Inline funetions are invoked at the time of
a. Run time
b. Compile time
¢. Depends on how it is invoked
d. Both b and c above
65. What is shallow copy?
a. A shallow copy creates a copy of the dynamically allocated objects
too.
b. A shallow copy just copies the values of the data as they
are.
c. A shallow copy ereates a copy of the statically allocated objects too
4. Both b and c above
66. What is deep copy?
a. A deep copy creates a copy of the dynamically allocated objects too.
b. A deep copy just copies the values of the data as they are.
htps:[Link]/c-programvming-muliple-choice-questions-and-answers!
weervs, 1028 Pa 20 C++ Programming Multiple Choice Questions and Answers
c. A deep copy creates a copy of the statically allocated objects too
d. Both b and c above
67. Which of the following below is /are a valid iterator
type?
a. Input Iterator
b. Backward Iterator
c. Forward Iterator
d. Both a and c above
68. What defines a general set of operations that will be
applied to various types of data?
a. Template class
b. Function template
c. Class template
d. Both a and c above
69. Under which of the following circumstances,
synchronization takes place?
a. When the file is closed
b. When the buffer is empty
c. Explicitly, with manipulators
d. both aande
70. Which of the following functions below can be used
Allocate space for array in memory?
a. calloc()
b. malloc()
c. Realloc()
d. both a and b
71, Statement seanf(“%d”,80);
a. Assign an integer to variable i
b. Give an error message
c. Print the value of i
4. Assign an float to variable i
htps:[Link]-programming-muliple-choice-questions-and-answers!
182697123, 10.28 Pat 300 C++ Programing Mutipe Coice Questions and Answers
72. STL is based on which of the following programming
paradigms?
a. Structured Programming
b. Object Oriented Programming (OOP)
c. Functional Programming
d, Aspect Oriented Programming (AOP)
73. STL is based on which of the following
programmingparadigms?
a, Structured Programming
b. Object Oriented Programming (OOP)
c. Functional Programming
d. Aspect Oriented Programming (AOP)
74. If there is more than one statement in the block of a for
loop, which of the following must be placed at the beginning
and the ending of the loop block?
a. parentheses ()
b. braces { }
c. brackets [ ].
d. arrows < >
75. Which of the following members do get inherited but
become private members in child class
a. Public
b. Private
c. Protected
d. All the above
76. Which looping process is best used when the number of
iterations is known?
a. for
b. while
c. do-while
d. all looping proces
require that the iterations be known
77. In aC language ‘3’ represents
a. A digit
htps:[Link]/c-programvming-muliple-choice-questions-and-answers!
19126911123, 1028 Pat 300 C++ Programming Multiple Croice Questions ang Answers
b. An integer
c. A character
d. Aword
78. Which of the following is the most common way of
implementing C++?
a. C++ programs are directly compiled into native code by a compiler
b. C++ programs are first compiled to intermediate code by a compiler
and then executed by a virtual machine
c. C++ programs are interpreted by an interpreter
d. AC++ editor directly compiles and executes the program
79. What is the benefit of e++ input and output over c input and
output?
a. Both Type safety & Exception
b. Sequence container
c. Exception
d. Type safety
80. Which of the following operators can be implemented
as a nonmember operator?
#NAME?
b. 0 (function call operator)
c. [. (array access operator)
d. + (addition operator)
81. What is the implicit pointer that is passed as the first
argument for nonstatic member functions?
a. ‘self pointer
b. std::auto_ptr pointer
c. ‘Myself pointer
d. ‘this’ pointer
82. Which of the following operators can be overloaded?
a. . (dot or member access operator)
b. & (address-of operator)
c. sizeof operator
d. ?: (conditional operator)
htps:[Link]/c-programvming-muliple-choice-questions-and-answers!
20726izs, 1028 PM 20 C++ Programming Multiple Choice Questions and Answers
83. Which of the following operator cannot be overloaded?
#NAME?
b. == (equality operator)
¢.—> (row operator)
d. :: (cope resolution operator)
84. Which of the following operators below allow to define
the member functions of a class outside the class?
ac:
b.?
.@
d.%
85. Which of the following is not a valid conditional
inclusions in preprocessor directives
a. #ifdef
b. #ifundet
c. #endif,
. #elif
86. Which of the following is not a standard exception built
in C++.
a. std::bad_creat
b. std::bad_alloc
c. std::bad_cast
d. std::bad_typeid
87. If amember needs to have unique value for all the
objects of that same class, declare the member as
a. Global variable outside class
b. Local variable inside constructor
¢. Static variable inside class
d. Dynamic variable inside class
88. Under which of the following circumstances,
synchronization takes place?
a. When the file is closed
htps:[Link]/c-programvming-muliple-choice-questions-and-answers!
218izs, 1028 PM 20 C++ Programming Multiple Choice Questions and Answers
b. When the buffer is empty
c. Explicitly, with manipulators
d. both a and
89. Which of the following functions below can be used
Allocate space for array in memory?
a. calloc()
b. malloc()
c. Realloc()
d. both a and b
90. Which of the following is not a valid conditional
inclusions in preprocessor directives
a. #ifdef
b. #ifundef
c. #endif,
. #elif
91. Value of a in a = (b = 5, b + 5); is
a. Junk value
b. Syntax error
c5
d.10
92. Minimum number of temporary variable needed to
swap the contents of 2 variables is:
at
b.2
3
d.o
93. How structures and classes in C++ differ?
a. Structures by default hide every member whereas classes do not
b. In Structures, members are public by default whereas,
in Classes, they are private by default
c. Structures cannot have private members whereas classes can have
d. In Structures, members are private by default whereas, in Classes,
they are public by default
[Link]-programvming-muliple-choice-questions-and-answers!
28izs, 1028 PM 20 C++ Programming Multiple Choice Questions and Answers
94. There is nothing like a virtual constructor of a class.
a. False
b. True
95. C++ provides facility to specify that the compiler should
match function calls with the correct definition at the run
time. This process is called as
a. Static binding
b. Dynamic Binding
96. The output of this program is
int
main () { cout << “Hello World!” return 0; }
a. Hello World
b. Syntax error
co
d. Hello World!
97. The return value of the following code is
Class1& test(Class1 obj)
{
Class: *ptr = new Classi;
return ptr;
+
a. object of Classi
b. reference to ptr
c. reference of Classi
d. object pointed by ptr
98. The output of
int b = 10;
htps:[Link]/c-programvming-muliple-choice-questions-and-answers!
2026rvs, 1028 Pa 20 C++ Programming Multiple Choice Questions and Answers
cout << (a>b?azb);
+
as
b.10
. Syntax error
d. None of above
99. The output of this program is
int a= 10;
void mainQ
{
inta = 20;
cout <