51. What will be the output of the following C# code?
class A
{
public int i;
private int j;
}
class B :A
{
void display()
{
base.j = base.i + 1;
Console.WriteLine(base.i + " " + base.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;
private int j;
}
class B :A
{
void display()
{
base.j = base.i + 1;
Console.WriteLine(base.i + " " + base.j);
}
}
class Program
{
static void Main(string[] args)
{
B obj = new B();
obj.i = 1;
obj.j = 2;
obj.display();
Console.ReadLine();
}
}52. Which of the given modifiers can be used to prevent Method overriding?
53. Which of the following keyword is used to change data and behavior of a base class by replacing a member of the base class with a new derived member?
54. Choose the wrong statement about 'INTERFACE' in C#.NET?
55. Selecting appropriate method out of number of overloaded methods by matching arguments in terms of number, type and order and binding that selected method to object at compile time is called?
56. If no access modifier for a class is specified, then class accessibility is defined as?
57. What will be the output of the following C# code?
static void Main(string[] args)
{
int a = 5;
int s = 0, c = 0;
Mul (a, ref s, ref c);
Console.WriteLine(s + "t " +c);
Console.ReadLine();
}
static void Mul (int x, ref int ss, ref int cc)
{
ss = x * x;
cc = x * x * x;
}
static void Main(string[] args)
{
int a = 5;
int s = 0, c = 0;
Mul (a, ref s, ref c);
Console.WriteLine(s + "t " +c);
Console.ReadLine();
}
static void Mul (int x, ref int ss, ref int cc)
{
ss = x * x;
cc = x * x * x;
}58. Number of constructors a class can define is?
59. Correct way to overload +operator?
60. The data members of a class by default are?
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.
