21. Which of the following is the correct result for the given statement in the C#.NET statement given below?
p = q
struct employee
{
private int employee id;
private string city;
}
employee q = new employee();
employee p;
p = q;
p = q
struct employee
{
private int employee id;
private string city;
}
employee q = new employee();
employee p;
p = q;22. The operator used to access member function of a class?
23. Select the statement which should be added to the current C# code to get the output as 10 20?
class baseclass
{
protected int a = 20;
}
class derived : baseclass
{
int a = 10;
public void math()
{
/* add code here */
}
}
class baseclass
{
protected int a = 20;
}
class derived : baseclass
{
int a = 10;
public void math()
{
/* add code here */
}
}24. Which among the following cannot be used as a datatype for an enum in C#.NET?
25. Which of the following statements about objects in "C#" is correct?
26. Which of these data types is used by the operating system to manage the Recursion in Csharp?
27. What will be the output of the following C# code?
interface calc
{
void cal(int i);
}
class displayA :calc
{
public int x;
public void cal(int i)
{
x = i * i;
}
}
class displayB :calc
{
public int x;
public void cal(int i)
{
x = i / i;
}
}
class Program
{
public static void Main(string[] args)
{
displayA arr1 = new displayA();
displayB arr2 = new displayB();
arr1.x = 0;
arr2.x = 0;
arr1.cal(2);
arr2.cal(2);
Console.WriteLine(arr1.x + " " + arr2.x);
Console.ReadLine();
}
}
interface calc
{
void cal(int i);
}
class displayA :calc
{
public int x;
public void cal(int i)
{
x = i * i;
}
}
class displayB :calc
{
public int x;
public void cal(int i)
{
x = i / i;
}
}
class Program
{
public static void Main(string[] args)
{
displayA arr1 = new displayA();
displayB arr2 = new displayB();
arr1.x = 0;
arr2.x = 0;
arr1.cal(2);
arr2.cal(2);
Console.WriteLine(arr1.x + " " + arr2.x);
Console.ReadLine();
}
}28. Select correct differences between '=' and '==' in C#.
29. The modifier used to hide the base class methods is?
30. 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)
{
this.width = w;
this.height = h;
this.length = l;
}
~ box()
{
volume = this.width * this.length * this.height;
console.writeline(volume);
}
}
class Program
{
public static void Main(string[] args)
{
box b = new box(4, 5, 9);
Console.ReadLine();
}
}
class box
{
public int volume;
int width;
int height;
int length;
public box ( int w, int h, int l)
{
this.width = w;
this.height = h;
this.length = l;
}
~ box()
{
volume = this.width * this.length * this.height;
console.writeline(volume);
}
}
class Program
{
public static void Main(string[] args)
{
box b = new box(4, 5, 9);
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.
