1. Which of the following is not automatically generated by the compiler?
A. Default constructor B. Copy constructor c. equality operator (op==) D. assignment operator (op=) E. destr Uctor
2, which of the following is not a STL collection?
A. Vector b. List c. map D. Tree E. Set
3, which statement is false?
A. Destructors was called when a pointer was deleted.
B. Destructors is called when a object goes out of scope.
C. Destructors is called when a reference goes out of scope.
D. A virtual destructor should is used if the class has virtual methods.
E. Base class destructors is called after derived class destructors.
4, what should you avoid calling from a constructor?
A. A static method B. An inlined method C. A Virual method d. A const method E. An extern method
5. Which of the following C + + operators cannot be overloaded?
A. << b. [] C. + + D. () E.:?
6. Consider the following function:
void foo (constChar* name) { char* Name1 = name; // constchar* Name2 = name; // charconst NAME3 = name; // charconst* Name4 = name; //
Which of the following is true?
A. Statement 1 fails to compile B. Statement 1 and 3 fails to compile
C. Statement 3 and 4 fails to compile D. statment 2 fails to compile
E. statment 3 and 4 fails to compile
7. Consider the following code:
struct mystruct{ int foo () {return1class myclass{ intreturn2int x = S.foo (); // int y = C.foo (); // Statement2
Circle one answer below which is true of the above code.
A. Statement 1 would cause a compilation error B. Statement 2 would cause a compilation error
C. Both statement would compilation successfully d. Both statement would fail to compile
8. Consider the following class:
class CLASSX { public: CLASSX (): C_ (1), B_ (2), A_ (b_+c_) {} Private: int a_; int b_; int c_;};
What value would the member variable A be initialized to?
A. 0 B. 1 c. 2 d. 3 E. None of the above
9. Name The design pattern is implemented in the following C + + class:
class XXX { public: static xxx * instance () { static return &x; } protected : { XXX () {}
A. Proxy B. Composite c. Singleton d. Factory E.adapter
10
Classfoo{ Public: Virtual voidCala () {cout<<"Foo"<<End1; }}classBar: Publicfoo{ Public: voidCalc () {cout<<"Bar"<<End1; }}intMain () {Bar* B1 =NewBar (); Bar B2; Foo F1= *B1; Foo&F2 =B2; Foo*F3 =B1; F1.calc (); F2.calc (); F3.calc (); }
Which of the output of the above code?
A. foo foo foo b. foo bar bar c. foo Foo bar d. Bar Bar E. Bar Foo Bar
C + + Test questions 1