31. Wrong statement about inheritance in C# .NET?
32. Correct way of declaration of object of the following class is?
class name
class name33. Select the sequence of execution of function f1(), f2() & f3() in C# .NET CODE?
class base
{
public void f1() {}
public virtual void f2() {}
public virtual void f3() {}
}
class derived :base
{
new public void f1() {}
public override void f2() {}
public new void f3() {}
}
class Program
{
static void Main(string[] args)
{
baseclass b = new derived();
b.f1 ();
b.f2 ();
b.f3 ();
}
}
class base
{
public void f1() {}
public virtual void f2() {}
public virtual void f3() {}
}
class derived :base
{
new public void f1() {}
public override void f2() {}
public new void f3() {}
}
class Program
{
static void Main(string[] args)
{
baseclass b = new derived();
b.f1 ();
b.f2 ();
b.f3 ();
}
}34. The following C# code is run on single level of inheritance. What will be the Correct statement in the following C# code?
class sample
{
int i = 10;
int j = 20;
public void display()
{
Console.WriteLine("base method ");
}
}
class sample1 : sample
{
public int s = 30;
}
class Program
{
static void Main(string[] args)
{
sample1 obj = new sample1();
Console.WriteLine("{0}, {1}, {2}", obj.i, obj.j, obj.s);
obj.display();
Console.ReadLine();
}
}
class sample
{
int i = 10;
int j = 20;
public void display()
{
Console.WriteLine("base method ");
}
}
class sample1 : sample
{
public int s = 30;
}
class Program
{
static void Main(string[] args)
{
sample1 obj = new sample1();
Console.WriteLine("{0}, {1}, {2}", obj.i, obj.j, obj.s);
obj.display();
Console.ReadLine();
}
}35. What is the return type of constructors?
36. Which keyword is used for correct implementation of an interface in C#.NET?
37. What will be the output of the following C# code?
public static void Main(string[] args)
{
p();
void p()
{
Console.WriteLine("hi");
}
}
public static void Main(string[] args)
{
p();
void p()
{
Console.WriteLine("hi");
}
}38. Can the method add() be overloaded in the following ways in C#?
public int add() { }
public float add(){ }
public int add() { }
public float add(){ }Read More Section(Classes and Objects in C Sharp)
Each Section contains maximum 100 MCQs question on Classes and Objects in C Sharp. To get more questions visit other sections.
