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?
- Use the existing functionality of base class.
- Overrride the existing functionality of base class.
- Implement new functionality in the derived class.
- Implement polymorphic behaviour.
- Implement containership.
A.1, 2, 3B.3, 4C.2, 4, 5D.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.PolymorphismB.TemplatesC.ContainershipD.EncapsulationE.Inheritance
In an inheritance chain which of the following members of base class are accessible to the derived class members?
-
static
-
protected
-
private
-
shared
-
public
A.1, 3B.2, 5C.3, 4D.4, 5