1. Question: Consider the following code:
    class A {
                  typedef int I;      // private member
                  I f();
                  friend I g(I);
                  static I x;
              };
    Which of the following are valid:

    A
    A::I A::f() { return 0; }

    B
    A::I g(A::I p = A::x);

    C
    A::I g(A::I p) { return 0; }

    D
    A::I A::x = 0;

    Note: Not available
    1. Report
  2. Question: In the given sample Code, is the constructor definition valid?
    class someclass
    {
       int var1, var2;
       public:
          someclass(int num1, int num2) : var1(num1), var2(num2)
          {
          }
    };

    A
    Yes, it is valid

    B
    No, we cannot assign values like this

    C
    No, the parenthesis cannot be empty

    D
    No, the parenthesis cannot be empty

    Note: Not available
    1. Report
  3. Question: Consider the following code:
    class BaseException
    {
    public:
       virtual void Output()
       {
          cout << "Base Exception" << endl;
       }
    };
    
    class DerivedException : public BaseException
    {
    public:
       virtual void Output()
       {
          cout << "Derived Exception" << endl;
       }
    };
    
    void ExceptionTest()
    {
       try
       {
          throw DerivedException();
       }
       catch (BaseException& ex)
       {
          ex.Output();
       }
       catch (...)
       {
          cout << "Unknown Exception Thrown!" << endl;
       }
    }
    Invoking Exception Test will result in which output?

    A
    Base Exception

    B
    Derived Exception

    C
    Unknown Exception Thrown

    D
    No Output will be generated

    Note: Not available
    1. Report
  4. Question: Consider the following code:
    #define SQ(a) (a*a)
    
    int  answer = SQ(2 + 3);
    What will be the value of answer after the above code executes?

    A
    10

    B
    11

    C
    25

    D
    13

    Note: Not available
    1. Report
  5. Question: Consider the following class hierarchy:
    class Base
    {
    }
    
    class Derived : private Base
    {
    }
    Which of the following are true?

    A
    The relation between Base and Derived can be described as: Base is a Derived

    B
    The relation between Base and Derived can be described as: Base has a Derived

    C
    Derived can access private member functions of Base

    D
    Derived can access public and protected member functions of Base

    Note: Not available
    1. Report
  6. Question: Consider the sample code given below and answer the question that follows:
    char **foo;
    /* Missing code goes here */
    for(int i = 0; i < 200; i++)
    {
    foo[i] = new char[100];
    }
    Referring to the sample code above, what is the missing line of code?

    A
    foo = new *char[200];

    B
    foo = new char[200];

    C
    foo = new char[200]*;

    D
    foo = new char*[200];

    E
    foo = new char[][200];

    Note: Not available
    1. Report
  7. Question: What will be the output of the following code?
    class A
    {
    public:
          A():pData(0){}
          ~A(){}
          int operator ++()
          {
                pData++;
                cout << "In first ";
                return pData;
          }
          int operator ++(int)
          {
                pData++;
                cout << "In second ";
                return pData;
          }
    private:
          int pData;
    };
    void main()
    {
         A a;
         cout << a++;
         cout << ++a;
    }

    A
    In first 1 In second 2

    B
    In second 1 In first 2

    C
    In first 0 In second 2

    D
    In second 0 In first 2

    Note: Not available
    1. Report
  8. Question: Which of the following are true about class member functions and constructors?

    A
    A constructor can return values but a member function cannot

    B
    A member function can declare local variables but a constructor cannot

    C
    A member function can declare local variables but a constructor cannot

    D
    A constructor can declare local variables but a member function cannot

    E
    A member function can throw exceptions but a constructor cannot

    Note: Not available
    1. Report
  9. Question: How many arguments can be passed to an overloaded binary operator?

    A
    4

    B
    3

    C
    2

    D
    1

    E
    0

    Note: Not available
    1. Report
  10. Question: What will happen when the following code is compiled and executed?
    #include<iostream>
    using namespace std;
    
    class myclass
    {
    private:
        int number;
    public:
        myclass()
        {
            number = 2;
        }
        int &a()
        {
            return number;
        }
    };
    
    int main()
    {
        myclass m1,m2;
        m1.a() = 5;
        m2.a() = m1.a();
        cout << m2.a();
        return 0;
    }

    A
    Compile time errors will be generated because right hand side of expressions cannot be functions

    B
    The printed output will be 5

    C
    The printed output will be 2

    D
    The printed output will be undefined

    Note: Not available
    1. Report
Copyright © 2024. Powered by Intellect Software Ltd