21. Which of these will happen if the recursive method does not have a base case?
22. Which operator among the following signifies the destructor operator?
23. What will be the output of the following C# code?
static void Main(string[] args)
{
int []a = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
func(ref a);
Console.ReadLine();
}
static void func(ref int[] x)
{
Console.WriteLine(" numbers are:");
for (int i = 0; i < x.Length; i++)
{
if (x[i] % 2 == 0)
{
x[i] = x[i] + 1;
Console.WriteLine(x[i]);
}
}
}
static void Main(string[] args)
{
int []a = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
func(ref a);
Console.ReadLine();
}
static void func(ref int[] x)
{
Console.WriteLine(" numbers are:");
for (int i = 0; i < x.Length; i++)
{
if (x[i] % 2 == 0)
{
x[i] = x[i] + 1;
Console.WriteLine(x[i]);
}
}
}24. What will be the output of the following C# code?
enum letters
{
a,
b,
c
}
letters l;
l = letters.a;
Console.writeline(l);
enum letters
{
a,
b,
c
}
letters l;
l = letters.a;
Console.writeline(l);25. What will be the output of the following C# code?
static void Main(string[] args)
{
int y = 3;
y++;
if (y <= 5)
{
Console.WriteLine("hi");
Main(args);
}
Console.ReadLine();
}
static void Main(string[] args)
{
int y = 3;
y++;
if (y <= 5)
{
Console.WriteLine("hi");
Main(args);
}
Console.ReadLine();
}26. What will be the output of the following C# code?
class maths
{
public int fun(int ii)
{
return(ii > 0 ? ii :ii * -1);
}
public long fun(long ll)
{
return(ll > 0 ? ll :ll * -1);
}
public double fun( double dd)
{
return(dd > 0 ? dd :dd * -1);
}
}
class Program
{
static void Main(string[] args)
{
maths obj = new maths();
int i = -25;
int j ;
long l = -100000l ;
long m;
double d = -12.34;
double e;
j = obj.fun(i);
m = obj.fun(l);
e = obj.fun(d);
Console.WriteLine(j + " " + m + " " + e);
Console.ReadLine();
}
}
class maths
{
public int fun(int ii)
{
return(ii > 0 ? ii :ii * -1);
}
public long fun(long ll)
{
return(ll > 0 ? ll :ll * -1);
}
public double fun( double dd)
{
return(dd > 0 ? dd :dd * -1);
}
}
class Program
{
static void Main(string[] args)
{
maths obj = new maths();
int i = -25;
int j ;
long l = -100000l ;
long m;
double d = -12.34;
double e;
j = obj.fun(i);
m = obj.fun(l);
e = obj.fun(d);
Console.WriteLine(j + " " + m + " " + e);
Console.ReadLine();
}
}27. In Inheritance concept, which of the following members of base class are accessible to derived class members?
28. Choose the wrong statement about structures in C#.NET?
29. A type of class which does not have its own objects but acts as a base class for its subclass is known as?
30. What will be the output of the following C# code?
class maths
{
public int fun1(int k)
{
k = 20;
return k;
}
public Single fun1(float t)
{
t = 3.4f;
return t;
}
}
class Program
{
static void Main(string[] args)
{
maths obj = new maths();
int i;
i = obj.fun1(30);
Console.WriteLine(i);
Single j;
j = obj.fun1(2.5f);
Console.WriteLine(j);
Console.ReadLine();
}
}
class maths
{
public int fun1(int k)
{
k = 20;
return k;
}
public Single fun1(float t)
{
t = 3.4f;
return t;
}
}
class Program
{
static void Main(string[] args)
{
maths obj = new maths();
int i;
i = obj.fun1(30);
Console.WriteLine(i);
Single j;
j = obj.fun1(2.5f);
Console.WriteLine(j);
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.
