Friday, September 1, 2017

C++ Quiz mcqs

1. What are the keywords used in exception handling?
Ans: try, catch, throw

2. A Base class 
Ans: is a generalized form of derived class

3. Following statements are equivalent: double balance[5]={1000.0,2.0,3.4,7.0,50.0}; and double balance[]={1000.0,2.0,3.4,7.0,50.0};
Ans: True

4. Which of the following cannot be virtual?
Ans: constructor

5. Arithmetic operators that can be used on pointers are 
Ans: ++, -, +, --

6. This method copies the address of an argument into the formal parameter. Inside the function, the address is used to access the actual argument used in the call. This means that changes made to the parameter affect the argument.
Ans: call by address

7. Function calling technique in C++ are
Ans: all of these (call by value, call by address, call by reference)

8. When our function doesn't need to return anything means, what will we use/send as parameter in function?
Ans: blank space

9. C++ allows a function to return an array
Ans: True

10. What is the output of the following code?

#include using namespace std;
struct a
{
int count;
};
struct b
{
int*value;
};
struct c: public a,public b{};
int main()
{
c*p=new c;
p->value=0;
cout<<"Executed successfully";
return 0;
}
Ans: Executed successfully

11. Which of the following keywords is used to keep the call by reference value intact?
Ans: const

12. In CPP, which of the following is not a correct variable type?
Ans: real

13. What is the output of this program?
#include using namespace std;
int main()
{
int x=5,y=5;
cout<<++x<<""<<--y<<endl;
return 0;
}
Ans: 6 4

14. How do we declare an interface class?
Ans: By making all the methods as pure virtual in class

15. Which of the following is default option for-leak-resolution in memcheck?
Ans: high

16. The keyword long is called?
Ans: modifier

17. Declaration of the addition operator that can be used to add two Box objects and returns final Box object is
Ans: Box operator+(const Box&)

18. Which of the following operator is overloaded for the object of class ostream?
Ans: <<

19. How many max number of arguments can present in function in c99 compiler?
Ans: 127.0

20. Can we declare a class without class name?
Ans: yes

21. This method copies the reference of an argument into the formal parameter. Inside the function, the reference is used to access the actual argument used in the call. This means that changes made to the parameter affect the argument.
Ans: call by reference

22. Which of the following is not a member of class?
Ans: friend function

23. Who designed C++?
Ans: Bjarne Stroustrup

24. Which of the following was the predecessors to C++?
Ans: C with Classes

No comments:

Post a Comment