71. What will be the Correct statement in the following C# code?
class sample
{
protected int index;
public sample()
{
index = 0;
}
}
class sample 1: sample
{
public void add()
{
index += 1;
}
}
class Program
{
static void Main(string[] args)
{
sample 1 z = new sample 1();
z . add();
}
}
class sample
{
protected int index;
public sample()
{
index = 0;
}
}
class sample 1: sample
{
public void add()
{
index += 1;
}
}
class Program
{
static void Main(string[] args)
{
sample 1 z = new sample 1();
z . add();
}
}72. Choose the correct statement about structures as to why they are defined as value types but not reference types?
73. What will be the output of the following C# code?
class A
{
public int i;
public void display()
{
Console.WriteLine(i);
}
}
class B: A
{
public int j;
public void display()
{
Console.WriteLine(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;
public void display()
{
Console.WriteLine(i);
}
}
class B: A
{
public int j;
public void display()
{
Console.WriteLine(j);
}
}
class Program
{
static void Main(string[] args)
{
B obj = new B();
obj.i = 1;
obj.j = 2;
obj.display();
Console.ReadLine();
}
}74. Does C#.NET support partial implementation of interfaces?
75. Which statement correctly defines Interfaces in C#.NET?
76. What will be the correct statement in the following C# code?
class trial
{
int i;
float d;
}
struct sample
{
private int x;
private Single y;
private trial z;
}
sample s = new sample();
class trial
{
int i;
float d;
}
struct sample
{
private int x;
private Single y;
private trial z;
}
sample s = new sample();77. What will be the output of the following C# code?
namespace ConsoleApplication4
{
abstract class A
{
public int i ;
public int j ;
public abstract void display();
}
class B: A
{
public int j = 5;
public override void display()
{
this.j = 3;
Console.WriteLine(i + " " + j);
}
}
class Program
{
static void Main(string[] args)
{
B obj = new B();
obj.i = 1;
obj.display();
Console.ReadLine();
}
}
}
namespace ConsoleApplication4
{
abstract class A
{
public int i ;
public int j ;
public abstract void display();
}
class B: A
{
public int j = 5;
public override void display()
{
this.j = 3;
Console.WriteLine(i + " " + j);
}
}
class Program
{
static void Main(string[] args)
{
B obj = new B();
obj.i = 1;
obj.display();
Console.ReadLine();
}
}
}78. What will be the correct statement in the following C# code?
struct book
{
private String name;
private int pages;
private Single price;
}
book b = new book();
struct book
{
private String name;
private int pages;
private Single price;
}
book b = new book();79. What will be the output of the following C# code?
static void Main(string[] args)
{
int x = 8;
int b = 16;
int C = 64;
x /= b /= C;
Console.WriteLine(x + " " + b+ " " +C);
Console.ReadLine();
}
static void Main(string[] args)
{
int x = 8;
int b = 16;
int C = 64;
x /= b /= C;
Console.WriteLine(x + " " + b+ " " +C);
Console.ReadLine();
}80. Which procedure among the following should be used to implement a 'Has a' or a 'Kind of' relationship between two entities?
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.
