C++ MCQ
Soopro Pathshala provides C++ MCQ(Multiple Choice Questions)
1. Who developed c++ languange?
a) Anders Hejlsberg
b) Bjarne Stroustrup
c) Dennis Ritchie
d) James Gosling
View Answer
Answer: (b) Bjarne Stroustrup
2. Identify the correct extension of the user-defined header file in C++.
a) .cpp
b) .hg
c) .h
d) .hf
View Answer
3. C++ uses which approach?
a) right-left
b) top-down
c) left-right
d) bottom-up
View Answer
4. Which of the following data type is supported in C++ but not in C?
a) int
b) bool
c) double
d) float
View Answer
5. Using which of the following data type can 19.54 be represented?
a) void
b) double
c) int
d) none
View Answer
6. Identify the correct function from which the execution of C++ program starts?
a) new()
b) start()
c) pow()
d) main()
View Answer
7. Identify the size of int datatype in C++.
a) 1 byte
b) 2 byte
c) 4 byte
d) depend on compiler
View Answer
Answer: (d) depend on compiler
8.Identify the correct syntax for declaring arrays in C++.
a) array arr[10]
b) array{10}
c) int arr[10]
d) int arr
View Answer
9. Identify the correct example for a pre-increment operator.
a) ++n
b) n++
c) --n
d) +n
View Answer
10. Which of the following loops is best when we know the number of iterations?
a) while loop
b) do while
c) for loop
d) all of above
View Answer
11. By which of the following can the if-else statement be replaced?
a) bitwise operator
b) logical operator
c) conditional operator
d) arithmetic operator
View Answer
Answer: (c) conditional operator
12. Which of the following is “address of operator”?.
a) *
b) &
c) []
d) &&
View Answer
13. Identify the scope resolution operator.
a) :
b) ::
c) ?
d) none
View Answer
14. goto can be classified into?
a) label
b) variable
c) operator
d) function
View Answer
15. Identify the correct definition of ‘*’ operator in pointer.
a) address of operator
b) value of address operator
c) multiplication operator
d) all of above
View Answer
Answer: (b) value of address operator
16. Choose the correct default return value of function.
a) int
b) void
c) char
d) float
View Answer
17. Choose the correct option which is mandatory in a function.
a) return_type
b) parameter
c) function_name
d) both a and c
View Answer
18. The constants in C++ are also known as?
a) pre-processor
b) literals
c) const
d) none
View Answer
19. What is the ASCII value of ‘\0’ character?
a) 32
b) 24
c) 48
d) 0
View Answer
20. Find the output of the following program.
main()
{
int a=7/0;
}
a) 0
b) compilation error
c) exception
d) none
View Answer
21. Which is more effective while calling the C++ functions?
a) call by object
b) call by pointer
c) call by value
d) call by reference
View Answer
Answer: (d) call by reference
22. Which of the following is used to terminate the function declaration in C++?
a) ;
b) ]
c) )
d) :
View Answer
23. The C++ code which causes abnormal termination/behaviour of a program should be written under _________ block.
a) catch
b) throw
c) try
d) finally
View Answer
24. What is abstract class in C++?
a) Any Class in C++ is an abstract class
b) Class from which any class is derivedn
c) Class specifically used as a base class with atleast one virtual functions
d) Class specifically used as a base class with atleast one pure virtual functions
View Answer
Answer: (d) Class specifically used as a base class with atleast one pure virtual functions
25. Which of the following constructors are provided by the C++ compiler if not defined in a class?
a) copy constructor
b) default constructor
c) assignment constructor
d) all of the mentioned
View Answer
Answer: (d) all of the mentioned
26. Which concept allows you to reuse the written code in C++?
a) Inheritance
b) Polymorphism
c) Abstraction
d) Encapsulation
View Answer
27. 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
View Answer
28. Which keyword is used to declare the friend function?
a) friend
b) firend
c) classfriend
d) myfriend
View Answer
29. What is the syntax of friend function?
a) friend class1 Class2;
b) friend class;
c) friend class
d) friend class()
View Answer
Answer: (a) friend class1 Class2;
30. Where does keyword ‘friend’ should be placed?
a) function declaration
b) function definition
c) main function
d) block function
View Answer
Answer: (a) function declaration
31. What is C++?
a) C++ is an object oriented programming language
b) C++ is a procedural programming language
c) C++ supports both procedural and object oriented programming language
d) C++ is a functional programming language
View Answer
Answer: (c) C++ supports both procedural and object oriented programming language
32. Which of the following is not a type of constructor in C++?
a) Default constructor
b) Parameterized constructor
c) Copy constructor
d) Friend constructor
View Answer
Answer: (d) Friend constructor
33. Which of the following is the correct syntax to add the header file in the C++ program?
a) #include
b) #include "userdefined.h"
c) "userdefined.h"
d) both a and b
View Answer
34. Which of the following is the address operator?
a) @
b) #
c) &
d) %
View Answer
35. Which of the following is the correct syntax to read the single character to console in the C++ language?
a) Read ch()
b) Getline vh()
c) get(ch)
d) Scanf(ch)
View Answer
36. Which one of the following represents the tab?
a) \n
b) \t
c) \r
d) none of the above
View Answer
37. Which type of memory is used by an Array in C++ programming language?
a) Contiguous
b) None-contiguous
c) Both a and b
d) Not mentioned
View Answer
38. What is the size of int in bits in C++?
a) 16
b) 32
c) 64
d) 8
View Answer
39. What is the size of long int in bits in C++?
a) 64
b) 32
c) 16
d) 8
View Answer
40. What is Class?
a) blue print architecture
b) ref type data type
c) both a and b
d) none of these
View Answer
Answer: (a) blue print architecture