C++ Programming MCQ (Multiple Choice Questions)
1. What is the full form of OOP
(A)Â Object-oriented programming
(B)Â Oriented object programming
(C)Â Office oriented programming
(D)Â office objective programming
2. What is the output of the below program?
int main()
{
int a = 10;
cout<<a++;
return 0;
}
(A) 10
(B) 11
(C) 12
(D) Not defined
3. Which operator has the highest precedence?
(A) ()
(B) =
(C) *
(D) ++
4. Which operator has the highest precedence in * / %?
(A)Â *
(B)Â /
(C)Â %
(D)Â all have the same precedence
5. How do we use structures to access and edit data in data file handling?
(A) read()
(B) write()
(C) both A and B
(D) without read()
6. What is the output of the below program?
int main()
{
const int a=10;
a++;
cout<<a;
return 0;}
(A) 10
(B) 11
(C) Compilation Error
(D) Linking Error
7. Can we overload functions in C++?
(A) Yes
(B) No
(C) Compilation Error
(D) Runtime Error
8. What is the correct syntax of for loop?
(A) for(initialization;condition; increment/decrement)
(B) for(increment/decrement; initialization; condition)
(C) for(initialization, condition, increment/decrement
(D) None of These
9. Can we typecast void * into int *?
(A) Yes
(B) No
(C) Undefined
(D) Depends on Compiler
10 . Which operator has more precedence in the below list?
(A) +
(B) –
(C) ++
(D) *
11. Which operator can not be overloaded?
(A) +
(B) –
(C) *
(D) ::
12. What is the size of the int data type in cpp?
(A) 2 Bytes
(B) 4 Bytes
(C) 1 Byte
(D) Depends on Compiler
13. What is the following operator called?
(A) Scope Resolution Operator
(B) Conditional Operator
(C) Ternary Operator
(D) if else o/p
14 . How many loops are there in C++ 98?
(A) 2
(B) 3
(C) 4
(D) 1
15. What is a dangling pointer?
(A)Â A pointer pointing to NULL
(B)Â Pointer pointing to a memory location which has been freed
(C)Â Pointer, which is pointing to a new location
(D)Â None of these
16. How many Access specifiers are there in C++?
(A) 1
(B) 2
(C) 3
(D) 4
17. Can this pointer point to another class?
(A) YES
(B)NO
18. What is VTable?
(A)Â It contains VPTR
(B)Â It contains the address of the Virtual function
(C)Â It contains the address of the Object
(D)Â None of these
19. Can we overload the Constructor?
(A) Yes
(B) No
20 . Can we create Nested classes in C++?
(A) Yes
(B) No
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 non-const objects
b. const members can be invoked only on const objects and not on non-const objects
c. non-const members can be invoked on const objects as well as non-const objects
d. none of the above
22. Which of the following relationships is known as an inheritance relationship?
a. ‘has-a’ relationship
b. ‘is-a’ relationship
c. association relationship
d. none of the above
23. If class A is a friend of class B, and class B is a friend of class C, which of the following is true?
a. Class C is a friend of Class A
b. Class A is a 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 records 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 the 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 data
b. Time taken by read/write head mechanism to position itself over appropriate cylinder
c. The appropriate sector takes Time to come under the read/write
d. None of the above
27. ‘Prime area’ in the context of the file system is defined as
a. It is the memory area created by the operating system
b. It is an area into which data records are written
c. It is the central area of a web page
d. None of the above
28. In multi-list organization
a. Records with equivalent Values for a given secondary index item are linked together to form a list.
b. Records are loaded in the ordered sequence defined by collating sequence by the content of the key
c. The record key field directly accesses records
d. None of the above
30. Where does the execution of the program start?
a) user-defined function
b) main function
c) void function
d) else function
31. What are the mandatory parts in the function declaration?
a) return type, function name
b) return type, function name, parameters
c) parameters, function name
d) parameters, variables
32. which of the following is used to terminate the function declaration?
a) :
b) )
c) ;
d) ]
33. Which of these won’t return any value?
a. void
b. null
c. free
d. empty
34. Which function do we use to check if a character is a space or a tab?
a. isdigit()
b. is blank()
c. isalnum()
d. is alpha()
35. What would happen if there was a void in the argument?
a. It would return any value
b. It may not or may depend on a declared return type of any function. The return type of the function is different from the passed arguments
c. It would return some value to the caller
d. It would not return any value to the caller
36. __________ is an ability to group certain lines of code that we need to include in our program.
a. macros
b. modularization
c. program control
d. specific task
37. Which keywords do we use to declare the friend function?
a. my friend
b. class friend
c. friend
d. friend
38. What is used for dereferencing?
a. pointer with asterisk
b. pointer without asterisk
c. Value with asterisk
d. Value without asterisk
39. What does polymorphism stand for?
a. a class that has four forms
b. a class that has two forms
c. a class that has only a single form
d. a class that has many forms
40. What handler do we use to handle all exceptions?
a. try-catch handler
b. catch-none handler
c. catch-all handler
d. catch handler
41. What do we use to throw an exception?
a. try
b. throw
c. handler
d. catch
42. We can apply RTTI to which of the class types?
a. Polymorphic
b. Encapsulation
c. Static
d. Derived
43. Which header file do we use to generate random numbers?
a. <random>
b. <generator>
c. <distribution>
d. <gen_dist>
44. Which container is the best for keeping a collection of various distinct elements?
a. queue
b. set
c. heap
d. multimap
45. Inheritance models: which type of relationship?
a. Belongs-to relationship
b. Part-Of relationship
c. Is-A relationship
d. Has-A relationship
46. In a heap, which values will be pointed out first?
a. First Value
b. Lowest Value
c. Third Value
d. Highest Value
47. Which functions are used for incrementing the iterator by a particular value?
a. move()
b. prev()
c. advance()
d. next()
48. In the locale object, which of these objects’ information is loaded?
a. secant object
b. facet object
c. instead object
d. both instead & facet objects
49. Which of these mathematics libraries is used in C++ for vector manipulation?
a. blitz++
b. stac++
c. vec++
d. cli+++
50. Which of these operators captures every external variable by reference?
a. *
b. &&
c. &
d. =
50. Expression C=i++ causes
a. Value of I assigned to C, and then I incremented by 1
b. I to be incremented by one, and then the Value of I assigned to C
c. Value of I assigned to C
d. I to be incremented by 1
51. The statement i++; is equivalent to
a. i = i + i;
b. i = i + 1;
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 functions below, by default, abort the program?
a. Terminate()
b. end()
c. Abort()
d. exit()
54. If a member needs to have a 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 a class
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 precision
56. Which of them can perform conversions between pointers and 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 constructors 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 exceptions of any type?
a. catch(std::exception)
b. catch(std::any_exception)
c. catch(…)
d. catch()
61. Which of the following is the most general exception handler that catches exceptions 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 most often?
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 regarding Access Modifier?
a. By default, all the struct members are private, while class members are public.
b. By default, all the struct members are protected, while class members are private.
c. By default, all the struct members are public, while class members are private.
d. By default, all the struct members are public, while class members are protected by default.
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 also creates a copy of the dynamically allocated objects.
b. A shallow copy copies the values of the data as they 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 also creates a copy of the dynamically allocated objects.
b. A deep copy 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 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 data types?
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 an array in memory?
a. calloc()
b. malloc()
c. realloc()
d. both a and b