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

300 C++ Programming Multiple Choice Questions and Answers

Uploaded by

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

300 C++ Programming Multiple Choice Questions and Answers

Uploaded by

Natanem Yimer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

HOME Interview Questions MCQs Class Notes *LAB VIVA SEMINAR TOPICS
ONLINE TEST GATE CAT Internship ABOUT US

Any Skill Sear


Home » C++ Programming Questions » 300 C++ Programming
Multiple Choice Questions and Answers

300 C++ Programming Multiple


Choice Questions and 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
(in 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

d. Wrapper 
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 1/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

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

4. Which one of the following is not a fundamental data


type in C++

a. float

b. string

c. int

d. wchar_t

5. Which of the following is a valid destructor of the class


name “Country”

a. int ~Country()

b. void Country()

c. int ~Country(Country obj)

d. void ~Country()

6. Which of the following correctly describes C++ language?

a. Statically typed language



https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 2/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

b. Dynamically typed language

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 


https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 3/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

10. What’s wrong? while( (i < 10) && (i > 24))

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

b. 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 conditional operator is only used with apstrings



https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 4/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

13. What’s wrong? for (int k = 2, k <=12, k++)

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 (typedefs)

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::list

c. std::map

d. std::set

16. Which of the following is not a standard exception built


in C++.


a. std::bad_creat

https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 5/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

b. std::bad_alloc

c. std::bad_cast

d. std::bad_typeid

17. What does STL stand for?

a. Simple Template Library

b. Standard Template Library

c. 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 compile-time binding

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.


https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 6/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

c. Overloading is a static or compile-time binding and Overriding is


dynamic or run-time binding

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

c. culmination

d. 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

https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 7/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

22. Which of the following relationship is known as


inheritancerelationship?
a. ‘has-a’ relationship
b. ‘is-a’ relationship
c. association relationship
d. none of the above

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 C is 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
c. 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
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

https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 8/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

c. It is 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. Both a & b
d. None of the above

30. *ptr++ is equivalenet to:


a. ptr++
b. *ptr
c. ++*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

https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 9/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

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

Free C
Exten

35. Latency time is:


Sider
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
b. Key sequence structure, exit sequenced structure
c. Entry sequence structure, exit sequenced structure
d. None of above

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 
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 10/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

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

40. 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 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
c. 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

https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 11/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

Free ChatGPT Brows


Extension

Sider

42. Which of the following language is not supported by


C++?
a. Exception Handling
b. Reflection
c. Operator Overloading
d. Namespaces

43. class derived: public base1, public base2 { } is an


example of
a. Polymorphic inheritance
b. Multilevel inheritance
c. Hierarchical inheritance
d. Multiple inheritance

44. Which of the following languages is a subset of C++


language?
a. C language
b. Java Language
c. C# language
d. language

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’ in a
class
c. By declaring the class as interface with the keyword ‘interface’
d. It is not possible to create interface class in C++ 
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 12/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

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. It is cost-effective
b. It has large storage capacity
c. It has highest speed
d. 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
c. 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. i to be incremented by 1 and then value of i assigned to C
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


a. i = i + i;
b. i = i + 1;

https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 13/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

c. i = i – 1;
d. i –;

52. In C language, a hexadecimal number is represented by


writing
a. x
b. xo
c. ox
d. h

53. Which of the following library function below by default


aborts the program?
a. Terminate()
b. end()
c. Abort()
d. exit()

Discover related topics

Java Mcq Questions and Answers Pdf

Questions and Answers

C++ Multiple Choice Questions and Answers Pdf

C++ Interview Questions and Answers Pdf

Oops Interview Questions and Answers Pdf

54. If a member 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
c. Static variable inside class


d. Dynamic variable inside class

https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 14/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

55. Value of ix+j, if i,j are integer type and ix long type
would be
a. integer
b. float
c. long integer
d. double percision

56. Which of the following below can perform conversions


between pointers to related classes?
a. cast_static
b. dynamic_cast
c. static_cast
d. cast_dynamic

57. How do we define a constructor?


a. x~() {}
b. X() {}~
c. X() ~{}
d. ~X() {}

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)

https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 15/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

c. catch(…)
d. catch()

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)
c. catch(…)
d. catch()

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 functions are invoked at the time of


a. Run time
b. Compile time
c. 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

https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 16/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

are.
c. A shallow copy creates a copy of the statically allocated objects too
d. 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.
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 a and c

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

https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 17/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

71. Statement scanf(“%d”,80);


a. Assign an integer to variable i
b. Give an error message
c. Print the value of i
d. Assign an float to variable i

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

https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 18/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

b. while
c. do-while
d. all looping processes require that the iterations be known

77. In a C language ‘3’ represents


a. A digit
b. An integer
c. A character
d. A word

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. A C++ editor directly compiles and executes the program

79. What is the benefit of c++ 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. () (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

https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 19/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

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)

83. Which of the following operator cannot be overloaded?


#NAME?
b. == (equality operator)
c. –> (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?

a. ::
b. ?
c. 😕
d. %

85. Which of the following is not a valid conditional


inclusions in preprocessor directives
a. #ifdef
b. #ifundef
c. #endif
d. #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 a member 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

https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 20/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

c. 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
b. When the buffer is empty
c. Explicitly, with manipulators
d. both a and c

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
d. #elif

91. Value of a in a = (b = 5, b + 5); is


a. Junk value
b. Syntax error
c. 5
d. 10

92. Minimum number of temporary variable needed to


swap the contents of 2 variables is:
a. 1
b. 2
c. 3
d. 0


https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 21/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

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

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
c. 0
d. Hello World!

97. The return value of the following code is

Class1& test(Class1 obj)


{
Class1 *ptr = new Class1();
………
return ptr;
}
a. object of Class1
b. reference to ptr

https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 22/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

c. reference of Class1
d. object pointed by ptr

98. The output of

{
int a = 5;
int b = 10;
cout << (a>b?a:b);
}

a. 5
b. 10
c. Syntax error
d. None of above

99. The output of this program is

int a = 10;
void main()
{
int a = 20;
cout << a << ::a;
}
a. Syntax error
b. 10 20
c. 20 10
d. 20 20

100. Observe following program and answer

class Example{
public: int a,b,c;
Example(){a=b=c=1;} //Constructor 1
Example(int a){a = a; b = c = 1;} //Constructor 2
Example(int a,int b){a = a; b = b; c = 1;} //Constructor 3
Example(int a,int b,int c){ a = a; b = b; c = c;} //Constructor
4 
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 23/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

}
In the above example of constructor overloading, the
following statement will call which constructor
Example obj = new Example (1,2,3);
a. Constructor 2
b. Constructor 4
c. Constrcutor 1
d. Type mismatch error

C++ Programming Mcqs Pdf ::

2 THOUGHTS ON “300 C++ PROGRAMMING MULTIPLE CHOICE


QUESTIONS AND ANSWERS”

aditya
JULY 8, 2016 AT 4:54 PM

pl. send me pdf of computer science subject

REPLY

aditya
JULY 8, 2016 AT 4:53 PM

sir please send me pdf of mcq on computer science. Its


nice collection

REPLY

LEAVE A REPLY

Your email address will not be published. Required fields are marked *

Comment *


https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 24/25
11/11/23, 5:08 PM 300 C++ Programming Multiple Choice Questions and Answers

Name *

Email *

Website

Post Comment

Engineering 2023 , Multiple Choice Questions and Answers for Engineering & Medical , Theme by Engineering|| Privacy
Policy|| Terms and Conditions|| ABOUT US|| Contact US||
Engineering interview questions,Mcqs,Objective Questions,Class Lecture Notes,Seminor topics,Lab Viva Pdf PPT Doc Book
free download. Most Asked Technical Basic CIVIL | Mechanical | CSE | EEE | ECE | IT | Chemical | Medical MBBS Jobs
Online Quiz Tests for Freshers Experienced .


https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-and-answers/ 25/25

You might also like