61. What will be the output of the following C# code?
static void Main(string[] args)
{
int i = 10;
double d = 35.78;
fun(i);
fun(d);
Console.ReadLine();
}
static void fun(double d)
{
Console.WriteLine(d);
}
static void Main(string[] args)
{
int i = 10;
double d = 35.78;
fun(i);
fun(d);
Console.ReadLine();
}
static void fun(double d)
{
Console.WriteLine(d);
}62. What will be the Correct statement in the following C# code?
class baseclass
{
int a;
public baseclass(int a1)
{
a = a1;
console.writeline(" a ");
}
class derivedclass : baseclass
{
public derivedclass (int a1) : base(a1)
{
console.writeline(" b ");
}
}
class program
{
static void main(string[] args)
{
derivedclass d = new derivedclass(20);
}
}
}
class baseclass
{
int a;
public baseclass(int a1)
{
a = a1;
console.writeline(" a ");
}
class derivedclass : baseclass
{
public derivedclass (int a1) : base(a1)
{
console.writeline(" b ");
}
}
class program
{
static void main(string[] args)
{
derivedclass d = new derivedclass(20);
}
}
}63. The process of defining a method in a subclass having same name & type signature as a method in its superclass is known as?
64. Wrong statement about enum used in C#.NET is?
65. What is the return type of destructor?
66. What will be the output of the following C# code?
class A
{
public int i;
protected int j;
}
class B : A
{
public int j;
public void display()
{
base.j = 3;
Console.WriteLine(i + " " + j);
}
}
class Program
{
static void Main(string[] args)
{
B obj = new B();
obj.i = 1;
obj.j = 2;
obj.display();
Console.ReadLine();
}
}
class A
{
public int i;
protected int j;
}
class B : A
{
public int j;
public void display()
{
base.j = 3;
Console.WriteLine(i + " " + j);
}
}
class Program
{
static void Main(string[] args)
{
B obj = new B();
obj.i = 1;
obj.j = 2;
obj.display();
Console.ReadLine();
}
}67. Access specifiers which can be used for an interface are?
68. A class consists of two interfaces with each interface consisting of three methods. The class had no instance data. Which of the following indicates the correct size of object created from this class?
69. Choose the correct statements among the following:
70. What will be the output of the following C# code?
class overload
{
public int x;
int y;
public int add(int a)
{
x = a + 1;
return x;
}
public int add(int a, int b)
{
x = a + 2;
return x;
}
}
class Program
{
static void Main(string[] args)
{
overload obj = new overload();
overload obj1 = new overload();
int a = 0;
obj.add(6);
obj1.add(6, 2);
Console.WriteLine(obj.x);
Console.WriteLine(obj1.x);
Console.ReadLine();
}
}
class overload
{
public int x;
int y;
public int add(int a)
{
x = a + 1;
return x;
}
public int add(int a, int b)
{
x = a + 2;
return x;
}
}
class Program
{
static void Main(string[] args)
{
overload obj = new overload();
overload obj1 = new overload();
int a = 0;
obj.add(6);
obj1.add(6, 2);
Console.WriteLine(obj.x);
Console.WriteLine(obj1.x);
Console.ReadLine();
}
}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.
