Vous êtes sur la page 1sur 4

-Creating Software Architects-

Test Paper

Programming in C++

1) Output for code below will be


class sample
{
public:
sample( ) {
cout<<"constructed";
throw 1; }

~sample( ) { cout<<"destructed:"; }
};

int main( )
{
try
{
sample s;
}
catch(int x){ cout<<"caught:"; }

return 0;
}

a) compile time error


b) constructed destructed caught
c) constructed caught
d) caught

2) following statement/statement are true about namespace in c++


a) avoids name clashes.
b) can be extend over multiple header files.
c) Controls the name visibility.
d) None of above

3) following statement / statements are true about static


a) maintains the value for variable across the function calls
b) specifier for internal linkage
c) used to with classes to declare sharable data
d) all of above
-Creating Software Architects-

4) following statement / statements are true about function template


a) it allows explicit specialization
b) it doesn’t allow for partial specialization
c) it never allows for default arguments
d) it allows full specialization

5) Consider a class having int* i, floa* j, float m, static int x as data members and
void f1( ), static void f2( ) as member functions. In a simple object model layout, size
of the object will be
a) 24 bytes
b) 12 bytes
c) 4 bytes
d) 16 bytes
assume VC++ compiler and 32 bit computing.

6) following statement/statements are true about static methods of a class


a) can access only static members
b) called through class name & ::
c) can be used for overloading operators in a class
d) only a & b

7) class A has two int data members and one static int member. It has two virtual
functions void f1( ) and void f2( ). Class B is derived from A having one double*
member. The size of object of B class will be
a) 16 bytes
b) 28 bytes
c) 24 bytes
d) 20 bytes

8) following statement/statements are true about constructors in C++


a) initialize object
b) you can have literal virtual constrcutor
c) inherited to derived class (subclass)
d) you can write static constructors to initialize static members of class

9) following statement/statements are true about destructors in C++


a) destructors can be virtual
b) destructor can be called explicitly in case of automatic storage, like
constructor
c) destructors can be overloaded like constructor
d) they are called by delete operator

10) following statement/statements are true about visitor design pattern


a) creating the objects
b) makes adding new operation easy
-Creating Software Architects-

c) code reusability
d) accumulating state of objects

11) following statement/statements are true about template method design pattern
a) define the skeloton of an algorthim in an operation, deffering some steps
to subclass.
b) technique for code reuse
c) controls the object accessibility
d) abstract out the object creation details

12) consider the following code, the o/p is


class A
{ public: A( ){ cout<<”A”;} };
class B: public A
{ public: B( ){ cout<<”B” ;} };

class C
{ public: C( ) {cout<< ”C”;}
private:
B bb;
};
int main( )
{
C cc;
}

a) ABC b) CBA c) BC d) CAB

13) Following provides RTTI


a) dynamic_cast b) typeid & type_info c) both d) reinterpret_cast

14) following statement/ statements are true about VTABLES in C++


a) generated by compiler at compile time
b) VTABLES are pointed by VPTR in object
c) Only one VPTR for each object in all scenarios of inheritance
d) generated by compiler at run-time

15) To share the object in memory by different client objects, following memory
management technique is used
a) copy-to-write
b) reference counting
c) singleton
d) all of above
-Creating Software Architects-

Vous aimerez peut-être aussi