php mcq questions with answers


                                

Which of the following statements is correct about constructors in C#.NET?

A.A constructor cannot be declared as private.
B.A constructor cannot be overloaded.
C.A constructor can be a static constructor.
D.A constructor cannot access static data.
E. this reference is never passed to a constructor.
                                

Which of the following can be facilitated by the Inheritance mechanism?

  1. Use the existing functionality of base class.
  2. Overrride the existing functionality of base class.
  3. Implement new functionality in the derived class.
  4. Implement polymorphic behaviour.
  5. Implement containership.

A.1, 2, 3
B.3, 4
C.2, 4, 5
D.3, 5
                                

Which of the following statements should be added to the subroutine fun( ) if the C#.NET code snippet given below is to output 9 13?

class BaseClass
{
    protected int i = 13;
}
class Derived: BaseClass
{
    int i = 9; 
    public void fun()
    {
        // [*** Add statement here ***]
    } 
}

A.Console.WriteLine(base.i + " " + i);
B.Console.WriteLine(i + " " + base.i);
C.Console.WriteLine(mybase.i + " " + i);
D.Console.WriteLine(i + " " + mybase.i);
E.Console.WriteLine(i + " " + this.i);
                                

Which of the following should be used to implement a 'Has a' relationship between two entities?

A.Polymorphism
B.Templates
C.Containership
D.Encapsulation
E.Inheritance
                                

In an inheritance chain which of the following members of base class are accessible to the derived class members?

  1. static
  2. protected
  3. private
  4. shared
  5. public

A.1, 3
B.2, 5
C.3, 4
D.4, 5