1.which of the following statements is correct? 1.change a reference changes the referent. 2.we can...

20
of the following statements is correc e a reference changes the referent. n create an array of references. correct. correct. d 2 are correct. d 2 are incorrect. ption A

Upload: solomon-powell

Post on 18-Jan-2016

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

1.Which of the following statements is correct?

1.Change a reference changes the referent. 2.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

Page 2: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

2.Which of the following statements is correct? 1.A reference is not a constant pointer. 2.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

Page 3: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

A. different B. same

C. Virtual D. class

3.A union that has no constructor can be initialized with another union of __________ type.

Answer: Option B

Page 4: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

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

Page 5: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

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

•Answer: Option C

Page 6: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

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

Page 7: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

123456789

#include < iostream.h >// empty class

class Sample{};

int main(){    Sample obj;    cout<< sizeof(Sample) <<","<< sizeof(obj);

    return 0;}

7.What will be the output of following program ?[what is the size of an object of an empty class?] 1.ERROR 1. 1,12.2,2 3. 3,34. 4,4 5. 0,0

Answer 1,1C++ 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.

Page 8: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

8.class Sample{ int anyVar;};int main(){ Sample obj; obj.anyVar=10; cout<< "value is= "<< obj.anyVar; return 0;}

1.value is= 102.value is= 03.value is= Garbage_value4.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.

Page 9: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

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

Page 10: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

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);• }a) ABCDEFGHIJ

b) AAAAAAAAAAc) JJJJJJJJd) none of the mentioned

Answer:a

Page 11: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

A. 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.

11.Which of the following statement is correct regarding destructor of base class?

Answer: Option B

Page 12: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

A. 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

12.Which of the following function prototype is perfectly acceptable?

Page 13: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

A.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

13.Which of the following statement is incorrect?

Page 14: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

A. housekeeping routineB. initializerC. ConstructorD. Compiler

Answer:Option C

14.If you design a class that needs special initialization tasks, you will want to design a(n) _____

Page 15: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

A. the generic class nameB. the keyword templateC. the keyword classD. the template definition

Answer:Option A

15.The type to be used in an instantiation of a class template follows ________

Page 16: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

A. []B. ->C. ?:D. *Answer: Option C

16.Which of the following operators cannot be overloaded?

Page 17: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

A. It cannot have a destructor.B. It cannot have a constructor.

C. It is not allowed.

D. Both A and B.Answer: Option D

17.What will happen if a class is not having any name?

Page 18: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

A.const int ShowData(void) { /* statements */ }

B.int const ShowData(void) { /* statements */ }

C.int ShowData(void) const { /* statements */ }

D. Both A and BAnswer: Option C

18.Which of the following is the correct way of declaring a function as constant?

Page 19: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

A. Virtual polymorphismB. Transient polymorphismC. Ad-hoc polymorphismD. Pseudo polymorphism

Which of the following correctly describes overloading of functions?

Answer Option c

Page 20: 1.Which of the following statements is correct? 1.Change a reference changes the referent. 2.We can create an array of references. A. Only 1 is correct

A. Top-down B. Bottom-upC. Right-left D. Left-right

20.Which of the following approach is adapted by C++?

:Answer Option B