C++ MCQ
C++ MCQ
Total Questions: 35
you'll have 25 second to answer each question.
Quiz Result
Total Questions:
Attempt:
Correct:
Wrong:
Percentage:
Quiz Answers
1. What are the actual parameters in C++?
Parameters with which functions are called
2. What are the formal parameters in C++?
Parameters which are used in the definition of the function
3. Which of the following is called insertion/put to operator?
<<
4. What will be the output of the following C++ code?
#include
#include
using namespace std;
int main(int argc, char const *argv[]) {
char s1[6] = "Hello";
char s2[6] = "World";
char s3[12] = s1 + " " + s2;
cout<
Error
5. By default, all the files in C++ are opened in _________ mode.
Text
6. What will be the output of the following C++ code?
#include
using namespace std;
int main() {
char c = 74;
cout << c;
return 0; }
J
7. What is meant by a polymorphism in C++?
class having many forms
8. Which concept allows you to reuse the written code in C++?
Inheritance
9. What will be the output of the following C++ code?
#include
using namespace std;
int main () {
int a, b, c;
a = 2;
b = 7;
c = (a > b) ? a : b;
cout << c;
return 0; }
7
10. Which keyword is used to declare the friend function?
friend
11. Where does keyword ‘friend’ should be placed?
function declaration
12. Which of the following operators can’t be overloaded?
::
13. Operator overloading is ___________
Defining multiple functions with the same name but different arguments
14. What is the syntax of overloading operator + for class A?
A operator+(argument_list){}
15. Which of the following operator can be overloaded?
==
16. What is a friend function in C++?
A function which can access all the private, protected and public members of a class
17. What is a copy constructor?
A constructor to initialize an object with the values of another object
18. How many types of constructors are there in C++?
3
19. What is the role of destructors in Classes?
To destroy an object when the lifetime of an object ends
20. What is syntax of defining a destructor of class A?
~A(){}
21. If same message is passed to objects of several different classes and all of those can respond in a different way, what is this feature called?
Polymorphism
22. Which type of function among the following shows polymorphism?
Virtual Function
23. Which feature can be implemented using encapsulation?
Abstraction
24. In multiple inheritance, if class C inherits two classes A and B as follows, which class constructor will be called first?
class A{ };
class B{ };
class C: public A, public B{ };
A()
25. Which object will be created first?
class student {
int marks;
};
student s1, s2, s3;
s1 then s2 then s3
26. Which among the following is correct for the class defined below?
class student {
int marks;
public:
student(){}
student(int x) {
marks=x;
} };
main() {
student s1(100);
student s2();
student s3=100;
return 0; }
Program runs and all objects are created
27. Size of a class is _____________
Classes doesn’t have any size
28. What is the scope of a class nested inside another class?
Depends on access specifier and inheritance used
29. Which of the following is not a kind of inheritance?
Distributed
30. Which of the following concept refers to adding new components to the program at the run time?
Data hiding
31. Among the following, which shows the Multiple inheritances?
X,Y->Z
32. Why inline functions are useful?
Usually, it is small, and we want to avoid the function calls
33. Which of the following not belongs to the rule of Virtual Functions?
Virtual functions can be static members.
34. ____________ refers to the act of representing only essential features without including the background details.
Data Abstraction
35. By default, members of the class are ____________ in nature.
private
No comments:
Post a Comment