Presentation is loading. Please wait.

Presentation is loading. Please wait.

1.Which of the following statements is correct?

Similar presentations


Presentation on theme: "1.Which of the following statements is correct?"— Presentation transcript:

1 1.Which of the following statements is correct?
Change a reference changes the referent. We can create an array of references. A. Only 1 is correct. B. Only 2 is correct. C. Both 1 and 2 are correct. D. Both 1 and 2 are incorrect. Answer: Option A

2 2.Which of the following statements is correct?
A reference is not a constant pointer. A referenced is automatically de-referenced. A. Only 1 is correct. B. Only 2 is correct. C. Both 1 and 2 are correct. D. Both 1 and 2 are incorrect. Answer: Option B

3 3.A union that has no constructor can be initialized
with another union of __________ type. A. different B. same C. Virtual D. class Answer: Option B

4 4.ios::ate is used for A. Set the initial position at the start of the file B. Set the last position at the end of the file C. Set the initial position at the end of the file D. Set the last position at the start of the file Answer: Option C

5 5.Which arithmetic operation can be done in pointer A. Multiplication
B. Division C. Addition D. None of above Answer: Option C

6 6.Stack unwinding deals with A. deals with polymorphism
B. deals with inheritance C. deals with exception handing D. deals with classes Answer: Option C

7 7. What will be the output of following program
7.What will be the output of following program ? [what is the size of an object of an empty class?] ERROR ,1 2, ,3 4. 4, ,0 1 2 3 4 5 6 7 8 9 #include < iostream.h > // empty class class Sample { }; int main()     Sample obj;     cout<< sizeof(Sample) <<","<< sizeof(obj);     return 0; } Answer 1,1 C++ allows to create object of an empty class, that will take some bytes of memory, and 1 is the minimum amount of memory. hence the class or object size of an empty class is 1.

8 8.class Sample {     int anyVar; }; int main()     Sample obj;     obj.anyVar=10;     cout<< "value is= "<< obj.anyVar;     return 0; } value is= 10 value is= 0 value is= Garbage_value ERROR Answer ERROR: can not access private members declared in class'Sample'. in C++ class default class access modifier is private and you can not access the private members outside of it's class.

9 9. The correct statement for a function that takes pointer to a float, a pointer to a pointer to a char and returns a pointer to a pointer to a integer is a) int **fun(float**, char**) b) int *fun(float*, char*) c) int ***fun(float*, char**) d) int ***fun(*float, **char) Answer:c

10 10.What is the output of this program?
#include <iostream> using namespace std; int main() { char arr[20]; int i; for(i = 0; i < 10; i++) *(arr + i) = 65 + i; *(arr + i) = '\0'; cout << arr; return(0); } ABCDEFGHIJ b) AAAAAAAAAA c) JJJJJJJJ d) none of the mentioned Answer:a

11 11.Which of the following statement is correct regarding destructor of base class?
Destructor of base class should always be static. B. Destructor of base class should always be virtual. C. Destructor of base class should not be virtual. D. Destructor of base class should always be private. Answer: Option B

12 12.Which of the following function prototype is perfectly acceptable?
int Function(int Tmp = Show()); B. float Function(int Tmp = Show(int, float)); C. Both A and B. D. float = Show(int, float) Function(Tmp); Answer: Option A

13 13.Which of the following statement is incorrect?
A default argument is checked for type at the time of declaration and evaluated at the time of call. B. We can provide a default value to a particular argument in the middle of an argument list. C. We cannot provide a default value to a particular argument in the middle of an argument list. D. Default arguments are useful in situations where some arguments always have the same value. Answer: Option B

14 A. housekeeping routine B. initializer C. Constructor D. Compiler
14.If you design a class that needs special initialization tasks, you will want to design a(n) _____ A. housekeeping routine B. initializer C. Constructor D. Compiler Answer: Option C

15 the template definition
15.The type to be used in an instantiation of a class template follows ________ A. the generic class name B. the keyword template C. the keyword class D. the template definition Answer: Option A

16 16.Which of the following operators cannot be overloaded?
[] B. -> C. ?: D. * Answer: Option C

17 17.What will happen if a class is not having any name?
It cannot have a destructor. B. It cannot have a constructor. C. It is not allowed. D. Both A and B. Answer: Option D

18 const int ShowData(void) { /* statements */ }
18.Which of the following is the correct way of declaring a function as constant? A. const int ShowData(void) { /* statements */ } B. int const ShowData(void) { /* statements */ } C. int ShowData(void) const { /* statements */ } D. Both A and B Answer: Option C

19 Which of the following correctly describes overloading of functions?
Virtual polymorphism B. Transient polymorphism C. Ad-hoc polymorphism D. Pseudo polymorphism Answer Option c

20 20.Which of the following approach is adapted by C++?
Top-down B. Bottom-up C. Right-left D. Left-right :Answer Option B


Download ppt "1.Which of the following statements is correct?"

Similar presentations


Ads by Google