41. Which of the following is the correct way to settle down values into the structure variable 'e' defined in the following C# code snippet?
struct emp
{
public String name;
public int age;
public Single sal;
}
emp e = new emp();
struct emp
{
public String name;
public int age;
public Single sal;
}
emp e = new emp();42. Which of the following keyword is used to overload user defined types by defining static member functions?
43. If base class consist of two private integers, one static integer and derived class consist of two static integers and one private integer. What would be the size of derived class object?
44. What will be the output of the following C# code snippet?
class maths
{
int fact(int n)
{
int result;
if (n == 1)
return 1;
result = fact(n - 1) * n;
return result;
}
}
class Output
{
static void main(String args[])
{
maths obj = new maths() ;
Console.WriteLine(obj.fact(4)*obj.fact(2));
}
}
class maths
{
int fact(int n)
{
int result;
if (n == 1)
return 1;
result = fact(n - 1) * n;
return result;
}
}
class Output
{
static void main(String args[])
{
maths obj = new maths() ;
Console.WriteLine(obj.fact(4)*obj.fact(2));
}
}45. What will be the output of the following C# code?
static void Main(string[] args)
{
Mul();
m();
Console.ReadLine();
}
static void Mul()
{
Console.WriteLine("4");
}
static void m()
{
Console.WriteLine("3");
Mul();
}
static void Main(string[] args)
{
Mul();
m();
Console.ReadLine();
}
static void Mul()
{
Console.WriteLine("4");
}
static void m()
{
Console.WriteLine("3");
Mul();
}46. Which among the following is the correct statement: Constructors are used to?
47. What will be the correct statement of the following C# code?
enum color:byte
{
yellow = 500,
green = 1000,
pink = 1300
}
enum color:byte
{
yellow = 500,
green = 1000,
pink = 1300
}48. Choose the correct statement about enum used in C#.NET?
49. What will be the output of the following C# code?
{
struct abc
{
int i;
}
class Program
{
static void Main(string[] args)
{
abc x = new abc();
abc z;
x.i = 10;
z = x;
z.i = 15;
console.Writeline(x.i + " " + y.i)
}
}
}
{
struct abc
{
int i;
}
class Program
{
static void Main(string[] args)
{
abc x = new abc();
abc z;
x.i = 10;
z = x;
z.i = 15;
console.Writeline(x.i + " " + y.i)
}
}
}50. What will be the output of the following C# code snippet?
class maths
{
public int fact(int n)
{
int result;
result = fact(n - 1) * n;
return result;
}
}
class Program
{
static void Main(string[] args)
{
maths obj = new maths();
Console.WriteLine(obj.fact(4));
Console.ReadLine();
}
}
class maths
{
public int fact(int n)
{
int result;
result = fact(n - 1) * n;
return result;
}
}
class Program
{
static void Main(string[] args)
{
maths obj = new maths();
Console.WriteLine(obj.fact(4));
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.
