61. What will be the output of the following C# code?
class maths
{
public int length;
public int breadth;
public maths(int x)
{
length = x + 1;
}
public maths(int x, int y)
{
length = x + 2;
}
}
class Program
{
static void Main(string[] args)
{
maths m = new maths(6);
maths k = new maths(6, 2);
Console.WriteLine(m.length);
Console.WriteLine(k.length);
Console.ReadLine();
}
}
class maths
{
public int length;
public int breadth;
public maths(int x)
{
length = x + 1;
}
public maths(int x, int y)
{
length = x + 2;
}
}
class Program
{
static void Main(string[] args)
{
maths m = new maths(6);
maths k = new maths(6, 2);
Console.WriteLine(m.length);
Console.WriteLine(k.length);
Console.ReadLine();
}
}62. Which of the following cannot be used to declare an interface correctly?
63. In an inheritance chain through which of the following, the base class and its components are accessible to the derived class?
64. What will be the output of the following C# code?
public class sample
{
public static int x = 100;
public static int y = 150;
}
public class newspaper :sample
{
new public static int x = 1000;
static void Main(string[] args)
{
console.writeline(sample.x + " " + sample.y + " " + x);
}
}
public class sample
{
public static int x = 100;
public static int y = 150;
}
public class newspaper :sample
{
new public static int x = 1000;
static void Main(string[] args)
{
console.writeline(sample.x + " " + sample.y + " " + x);
}
}65. Which of the following is used to define the member of a class externally?
66. Which of these can be overloaded?
67. What will be the output of the following C# code?
class box
{
public int volume;
int width;
int height;
int length;
public box ( int w, int h, int l)
{
width = w;
height = h;
length = l;
}
public ~box()
{
volume = width * length * height;
}
}
class Program
{
static void Main(string[] args)
{
box b = new box(4, 5, 9);
Console.WriteLine(b.volume);
Console.ReadLine();
}
}
class box
{
public int volume;
int width;
int height;
int length;
public box ( int w, int h, int l)
{
width = w;
height = h;
length = l;
}
public ~box()
{
volume = width * length * height;
}
}
class Program
{
static void Main(string[] args)
{
box b = new box(4, 5, 9);
Console.WriteLine(b.volume);
Console.ReadLine();
}
}68. Operator used to free the memory when memory is allocated?
69. Choose the statements which makes interface different from classes?
70. What will be the output of the following C# code?
using System;
public class BaseClass
{
public BaseClass()
{
Console.WriteLine("I am a base class");
}
}
public class ChildClass : BaseClass
{
public ChildClass()
{
Console.WriteLine ("I am a child class");
}
static void Main()
{
ChildClass CC = new ChildClass();
}
}
using System;
public class BaseClass
{
public BaseClass()
{
Console.WriteLine("I am a base class");
}
}
public class ChildClass : BaseClass
{
public ChildClass()
{
Console.WriteLine ("I am a child class");
}
static void Main()
{
ChildClass CC = new ChildClass();
}
}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.
