Manhattan  Placement Paper      -1 Jan 1900

Manhattan  Placement Paper      -1 Jan 1900


  • Posted by  FreshersWorld 
    7 Jan, 2012

    MANHATTAN INTERVIEW QUESTIONS

     

     

     

    1. What is the output of the code snippet below?

            Int main(int argc,int* argv[])

            {

                    Int x=1;

                    For(int i=0;i<100;++i);

                            X++;

                    Cout<

                    Return 0;

            }

     

    A.100

    B.2

    C.1

    D.99

     

    2. Class B is (publicly) derived from class A. Global function func  is declared to be A?s friend. What level of access does func have to member variables in A and B?

     A.func can access private and protected member variables of Aand B.

    B. func can access only protected member variables A and B.

    C. func can access private and protected member variables of A.

    D. func can access private and protected member variables of B.

     

    3. Given the statement:

    Which of the following statements best replaces the one above?

    A.short s= const_cast (3L);

    B. short s= dynamic_cast (3L);

     

    C. short s= reinterpret_cast (3L);

    D. short s= static_cast (3L);

     

    4. Which option is correct for the code snippet below?

    Class CBase {public:virtual~CBase(){} };

    Class CDerived : public CBase { };

    CBase b; CBase *pb;

    CDerived d; CDerived *pd;

    Pd=dynamic_cast (&b);

     

    A.   Dynamic cast allowed here and will work as expected.

    B.   Compiler error.

    C.   RTTI error during runtime.

    D.  Null pointer on this type-cast.

     

    5. What is the output of the code snippet below?

            Class X{

                    Public :

                            X(char*str):m_str(str){cout<< ? X?<

                            ~X(){cout<< ?~X?<

                    Private:

                            Char*m_str;

    };

    Int main (int argc,int*argv[])

    {

            Xx(?1?);

            {

                    Xx(?2?);

            }

    }

     

    A.   X1X2~X2~X1

    B.    X1X2~X1~X2

    C.   Complication error ? ?redefinition of x?

    D.  X1~X1X2~X2.

     

    6. What is the output of this code snippet?

            String a1 = ?hello?;

            String a2 = ?world?;

            String*s1 =&a2;

    String& s2 = a1;

    S1 = &a1;

    S2 = a2;

    Std::cout <<*s1<<  ?  ?<

     

    A.hello world!

    B.world! World!

    C.Address of a1 world!

    D.hello world! World!

     

    7. Select the most appropriate option after reviewing the code snippet below

            Class X

            {

            Public:

                 X():m_plnt(new int()){}

                 X(X & rhs){m_plnt = rhs.m_plnt; }

         Void setvalue (int value){*m_plnt =value; }

         Int getvalue ( ){return*m_plnt; }

     

    Private:

            Int*m_plnt;

    };

    Int main (int argc,int*argv{})

    {

    Xobj1;

    Obj1.setvalue(100);

    Xobj2(obj1);

    Obj2.setvalue(200);

    Cout<

    Return 0;

    }

     

    A.   The output is 200-200 but there is a memory leak in the program.

    B.   The output is 200-200 and there is no memory leaks in the program.

    C.   The output is 200-200 and there are no memory leaks in the program.

    D.  The output is 100-200 but there is a memory leak in the program.

     

    8. what will be the result of the code snippet below?

            Void show()

            {

                 Static int n=1;

                Cout<

    }

            Int main(int argc,int*argv[])

            {

              Show ();show(); show();

              Return 0;

            }

     

            A. 111.

            B. 234.

            C. 123.

            D. None of the above.

    9. What will be the result of the code snippet below?

                   Class A

            {

    Public:

            A():m_int(A::s_int){s_int++;}

            Int getstaticvalue(){return s_int;}

            Int getmemvalue(){return m_int;}

            Private:

            Static int s_int;

            Int m_int;

            };

           

            Int A::s_int=0;

            Int main(int argc,int*argv[])

            {

    Aaobj1;

    Cout<

    Aaobj2;

    Cout<

    }

     

    A.01

    B.02

    C.13

    D.12

     

    10. Select the option that correctly describes the code snippet below:

            Class Foo {public: virtual func ()=0;};

            Class Bar: public Foo{public:virtual  func() {cout<<?func?;} };

           

    Int main (int argc,int*argv[])

            {

            Foo *f = new bar();

            f->func ();//line 1

            f=new Foo();//line 2

           

     

    f->func();//line 3

    return 0;

    } 

           

    A.   Compilation error at line 1-cannot use pointer of the type Foo to call a method on type bar.

    B.   Compilation error at the line 2-cannot create a Foo object.

    C.   Compilation error at the line ?cannot call func on a pointer to object  of tyoe Foo.

    D.  Program compiles fine and the result is funcfunc.

     

    11. What is the result of the code snippet below:

            Class BaseEx{

            Public:virtual void printMe(){cout<<?Base Ex?;}

            };

            Class childEx:public BaseEx{

                Public:virtual void printMe(){cout<<?child Ex?;}

            };

           

            Int main(int argc,int*argv[])

            {

            Try {childEx;throw ex; }

            Catch(base Ex ex){ex.printMe(); }

            Catch(childEx ex){ex.printMe(); }

            Return );

            }

           

            A.child Ex.

            B.child Exbase Ex.

            C.Base Ex.

            D.Base Exchild Ex.

     

    12. please read the statement about an inline function  and then chose the approptiate option.

            1.An inline function is always enforced by the compiler.

            2.An inline function is a request to the compiler and need not to be enforced.

            3. An inline function is safer than a macro because it provides type checking.

            4.An inline function evaluates expressions passed into it only once.

           

    A.only statements 1,3 and 4 are correct.

    B.only statement 2,3 and 4 are correct.

    C.only statements 3 and 4 are correct.

    D.only statements 2 and 3 are correct.

     

    13. Select the most approptiate result for the code snippet below.

            Void g1(std::string& S){};

            Void f1(std::string const & s)

    {

                    g1(s);    //line 1

                    std::string local copy =s ;//line 2

                    g1(localcopy);//line 3

    }
           

    A.   compilation error at line 1

    B.   compilation error at line 2

    C.   compilation error at line 3

    D.  the program will compile without errors.

    14. what will be the result of the code snippet below

            Class fred

            {

            Public:

            Fred(int i,int j){cout<?X?;};

            };

    Int main()

            {

            Fred a[2];

            Fred *p = new fred [2];

    }

     

    A.xxxx.

    B.xx.

    C .runtime error.

    D.compilation error.

     

    15. Consider the c++ statements below and choose the most approptiate option:

            1. int x=4;const int& y=x;

            2. float f=2.4;short s=f;

            3. char c=?A?;const char*const p =&c;

            4. struct s {int m,n;} q={0};

            Note :ignore compiler warnings if any while selecting an option below.

           

            A.only statements 2,3 and 4 will compile.

            B. only statements 1,3 and 4 will compile.

            C. All the statements will compile.

            D.none of the statements will compile.

     

    16. What is the most appropriate option for the code snippet below

            Class myint

            {

            Public:

            Myint (int value):m_int(value){ }

            Myint&operator++(){++m_int; return *this;}

             Myint operator++(int){myint tmp(*this);++m_int;return tmp;}

            Private:

                Int m_int;

            For the ++operator that is overloaded in class myint:

           

            A.the prefix implementation is more efficient than the postfix.

            B.the postfix implementations are equally efficient than prefix.

            C.prefix and postfix implementations are equally efficient.

            D.none of the above.

    17. select the most approptiate statement from the option below

    A.constructors is fired in the sequence ?base to derived? and destructors are fired in the sequence ?base to derived?.

    B. constructors are fired in the sequence ?base to derived? and destructors are fired in the sequence ?derived to Base?.

    C. constructors are fired in the sequence ?derived to Base? and destructors are fired in the sequence ?base to derived?.

    D.constructor and destructor sequences are compile dependent.

    18. Following pseudo-code demonstrates a basic multi-thread program APIs for threading have been used as required.select the appropriate result of the pseudo-code

            Void fun(int i)

            {

            Cout <

            }

            Int main(int argc,int*argvp[])

            {

                Create thread 1 and call function fun by passing value 1.

                Create thread 2 and call function fun by passing value 2

            }

     

            A.12

            B.21

            C. Random order

            D.potential crash.

     

     

     

     

     

     

     

    19. Consider the following tables and data in an RDBMS database.

            Table: order

    Order ID

    Address _line1

    Total _order_quantity

    1

    ABCD

    5

    2

    PQRS

    2

    3

    ABCD

    3

     

    TABLE: ORDER_LINE_ITEM

    ORDER id

    Item code

    Quantity

    1

    Item1

    2

    1

    Item2

    2

    1

    Item3

    1

    2

    Item1

    2

    3

    Item3

    1

    3

    Item1

    2

     

    Read the statements below and choose the most appropriate option from the option that follows

     

    1. Order _line _item.order_id is an ideal candidate for a foreign key.

    2. Order.order id is an ideal candidate for a primary key.

    3. Order_ line_item.quantity is an ideal candidate for a unique constraint.

    4. Order has no redundant data.

     

    A. only statements 1 and 3 are correct.

     B. only statements 2 and 4 are correct.

    C. only statements 1 and 2 are correct.

    D. All the statements are correct.

           

    20. What are the ACID properties of a database transaction?

            A. Atomicity,consistency,isolation,durability.

            B.applicability,conformance to standards,intelligent data exchange,damage resistance.

            C.atomicity,cohesiveness,isolation,durability.

            D.applicability,consistency,isolation,durability.

     

     

     

2009-2016 downloadmela.com. All rights reserved.