Try to answer these 600+ C++ MCQs and check your understanding of the C++ subject.
Scroll down and let's begin!
A. Operating on Objects in Design
B. Object-Oriented Design
C. Overly Objective Design
D. Object-oriented database
A. Always 0.
B. It's depend of double implementation, usually not exactly zero.
C. Always not 0.
A. private
B. protected
C. public
D. Visibility is defined for classes only.
A. true
B. false
A. inline functions.
B. recursive functions.
C. function overloading.
A. int a; b; c;
B. int a, b, c;
C. int a:
A. Hash symbol (#)
B. Colon (:)
C. Semi-colon (;)
D. Addition sign (+)
A. int myFunction( int a, int b)
B. myFunction( int a, int b)
C. void myFunction( int a, int b)
A. declare x as integer;
B. int x;
C. x int;
D. int<x>;
E. x is integer;
A. stop when loop
B. do while loop
C. for loop
A. char
B. wide
C. bool
A. ?
B. ,
C. :%
D. ::
A. int
B. real
C. float
D. double
A. None of these options
B. if( (sum == 10) || (total < 20) )printf(
C. if( (sum == 10) && (total < 20) )printf(
D. ctrl+alt+del
A. myfunction(void)
B. void myfunction()
C. myfunction()
A. CHAR
B. char
C. character
D. Char
A. a = b;
B. a = &b;
C. a = *b;
A. Both of these
B. /* this is a comment */
C. // this is a comment
A. True
B. False
A. The value of a cannot change from 50.
B. The initial value of a is 50 but you can change it.
C. none of these
A. a leading //.
B. all of these
C. a leading /**.
A. 4
B. 4.36
C. 4.4
D. 5
A. The maximum integer value that can be placed in the array.
B. The initial value of the first array element.
C. The number of integer elements the array shall hold.
A. printmsg();
B. void printmsg();
C. printmsg;
A. Yes
B. No
C. Depends on the situation.
A. reduce code duplication
B. templates are typesafe
C. all of these
D. increase code flexibility
A. int myFunction( int a, int b);
B. all of these
C. int myFunction(int, int);
A. none of these
B. can be accessed by all objects of the same class.
C. their values will change for each object of the same class.
A. returns the maximum value of arg
B. returns the size in bytes of arg
C. returns the length in characters of arg
A. You can declare functions in a class, you cannot declare functions in a struct.
B. They are the same.
C. You cannot overload an operator in a struct.
D. The members of a class are private by default, and the members of a struct are public by default.
A. True
B. False
A. 4,4,4,4
B. 0,1,2,3
C. 4,5,6,7
D. 1,2,3,4
A. It will declare a new variable a and set it to 97 (assuming a machine that uses ASCII).
B. It will declare a new variable a and set it to its previous value.
C. It will cause an infinite loop.
D. Nothing, it is an error and won't compile.
A. Freeing memory which has already been freed.
B. All of these
C. Using an address before memory is allocated and set.
A. value contained in the address of a
B. address of a
C. 25
A. dynamic_cast
B. reinterpret_cast
C. unknown_cast
D. const_cast
A. *(myItem.units)
B. myItem->units
C. myItem.units
A. different types in C++.
B. alternate names for existing types in C++.
A. m_test
B. 1_str
C. class
A. It tells the program to include the standard library header files.
B. It tells the preprocessor to include the iostream standard file.
C. It tells the preprocessor to include the iostream standard file only if it it required by the program.
A. rectangle::move circle::move shape::move
B. Compile error
C. Runtime error
D. shape::move shape::move shape::move
E. shape::move circle::move rectangle::move
A. Declares a volatile virtual function.
B. Declares a pure virtual function.
C. Causes a compiler error.
D. Declares a default virtual function.
A. Initializes a vector with 5 elements of value 0.
B. Initializes a vector with an element with the value 5.
A. In all directories specified by the PATH environment variable on the machine.
B. In the default directories where it is configured to look for the standard header files
C. The same directory that includes the file containing the directive.
A. Nothing, that is not a valid C++ expression.
B. 0
C. -2
D. 2
E. 4
A. True
B. False
A. The function must be defined as the friend function.
B. The function must be defined inside the class.
C. The function must be defined outside the class.
A. No difference.
B. There are no inheritances with structs. Classes may be derived.
C. Structs only allow variable definitions. Classes also allow function definition.
D. Structs have public privacy by default, classes use private.
A. 8
B. 6
C. 7
A. The second one is illegal.
B. The first one is illegal.
C. None, they are equivalent.
D. One of them takes no value, the other takes any value.