C-Plus-Plus Questions March 21, 2023 | No Comments 0 votes, 0 avg 28 123456789101112131415 C-Plus-Plus Questions 1 / 15 1. What should be printed on screen? int main() { int x = 5; if(x++ == 5) cout<<"Five"< A. FiveSix B. Five C. Six D. None of these 2 / 15 2. Exceptions are Caught at ? A. Compilation Time B. Run Time C. Linking Time D. None of the above 3 / 15 3. Under which pillar of OOPS does base class and derived class relationship come? A. Polymorphism B. inheritance C. Encapsulation D. Abstraction 4 / 15 4. Choose the correct option which is mandatory in a function. A. return_type B. parameters C. function_name D. both a and c 5 / 15 5. What will be the output of the following C++ code? #include using namespace std; void square (int *x, int *y) { *x = (*x) * --(*y); } int main ( ) { int number = 30; square(&number, &number); cout << number; return 0; } A. 30 B. Error C. Segmentation fault D. 870 6 / 15 6. Which of the following statement is correct about Virtual Inheritance? A. It is a technique to ensure that a private member of a base class can be accessed B. It is a technique to optimize the multiple inheritances C. It is a technique to avoid the multiple inheritances of the classes D. It is a C++ technique to avoid multiple copies of the base class into the derived or child classes 7 / 15 7. What is the use of is_same() function in C++? A. To check if a variable is array type or not B. To check whether two variables have the same characteristics C. To check if two variable is of array type or not D. To check whether two variables are different or not 8 / 15 8. What is do-while loop also known as? A. Exit Control B. Entry Control C. Per Tested D. all of the above 9 / 15 9. Which of the following can be used to create an abstract class in the C++ programming language? A. By declaring a virtual function in the base class B. By using the pure virtual function in the class C. By declaring the virtual keyword afterward, the class Declaration D. None of the above 10 / 15 10. Which option is false for the following code? class A { private : int sum(int x, int y) { return x+y; } public: A() { } A(int x, int y) { cout< A. Constructor can be created with zero argument B. Constructor prints sum, if two parameters are passed with object creation C. Constructor will give error if float values are passed D. Constructor will take 0 as default value of parameters if not passed 11 / 15 11. What will be the output of the following C++ code? #include using namespace std; double & WeeklyHours() { double h = 46.50; double &hours = h; return hours; } int main() { double hours = WeeklyHours(); cout << "Weekly Hours: " << hours; return 0; } A. 46.5 B. 6.5 C. compile time error D. 26.5 12 / 15 12. What is virtual inheritance in C++? A. C++ technique to enhance multiple inheritance B. C++ technique to ensure that a private member of the base class can be accessed somehow C. C++ technique to avoid multiple inheritances of classes D. C++ technique to avoid multiple copies of the base class into children/derived class 13 / 15 13. Which of the following is correct about this pointer in C++? A. this pointer is passed as a hidden argument in all static variables of a class B. this pointer is passed as a hidden argument in all the functions of a class C. this pointer is passed as a hidden argument in all non-static functions of a class D. this pointer is passed as a hidden argument in all static functions of a class 14 / 15 14. What will be the output of the following C++ code? #include using namespace std; #define PI 3.14159 int main () { float r = 2; float circle; circle = 2 * PI * r; cout << circle; return 0; } A. 12.5664 B. 13.5664 C. 10 D. 15 15 / 15 15. What is the correct definition of an array? A. An array is a series of elements of the same type in contiguous memory locations B. An array is a series of element C. An array is a series of elements of the same type placed in non-contiguous memory locations D. An array is an element of the different type Your score is The average score is 16% LinkedIn Facebook Twitter VKontakte 0% Restart quiz Questions, Quiz