Select an option to see the answer and solution.
Classes and Objects in C Sharp
practice.
Practice every MCQ with options. Use Show answers when you want the correct option and solution.
238
Questions
5/12
Page
Pick an option on a question to see the right answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
namespace ConsoleApplication4
{
abstract class A
{
int i;
public abstract void display();
}
class B: A
{
public int j;
public override void display()
{
Console.WriteLine(j);
}
}
class Program
{
static void Main(string[] args)
{
B obj = new B();
obj.j = 2;
obj.display();
Console.ReadLine();
}
}
}Select an option to see the answer and solution.
class maths
{
static maths()
{
int s = 8;
Console.WriteLine(s);
}
public maths(int f)
{
int h = 10;
Console.WriteLine(h);
}
}
class Program
{
static void Main(string[] args)
{
maths p = new maths(0);
Console.ReadLine();
}
}Select an option to see the answer and solution.
enum days:int
{
sunday = -3,
monday,
tuesday
}
Console.WriteLine((int)days.sunday);
Console.WriteLine((int)days.monday);
Console.WriteLine((int)days.tuesday);Select an option to see the answer and solution.
static void Main(string[] args)
{
int X = 6,Y = 2;
X *= X / Y;
Console.WriteLine(X);
Console.ReadLine();
}Select an option to see the answer and solution.
Select an option to see the answer and solution.
class a
{
}
class b : a
{
variable declaration;
method declaration;
}Select an option to see the answer and solution.
interface abc
{
String FirstName
{
get;
set;
}
String LastName
{
get;
set;
}
void print();
void stock();
int fun();
}Select an option to see the answer and solution.
interface i1
{
void f1();
}
interface i2 :i1
{
void f2();
}
public class maths :i2
{
public void f2()
{
Console.WriteLine("fun2");
}
public void f1()
{
Console.WriteLine("fun1");
}
}
class Program
{
static Void Main()
{
maths m = new maths();
m.f1();
m.f2();
}
}Select an option to see the answer and solution.
namespace ConsoleApplication4
{
abstract class A
{
public int i;
public abstract void display();
}
class B: A
{
public int j;
public int sum;
public override void display()
{
sum = i + j;
Console.WriteLine(+i + "\n" + +j);
Console.WriteLine("sum is:" +sum);
}
}
class Program
{
static void Main(string[] args)
{
A obj = new B();
obj.i = 2;
B obj1 = new B();
obj1.j = 10;
obj.display();
Console.ReadLine();
}
}
}Select an option to see the answer and solution.
Select an option to see the answer and solution.
class maths
{
public int length;
public int breadth;
public maths(int x, int y)
{
length = x;
breadth = y;
Console.WriteLine(x + y);
}
public maths(double x, int y)
{
length = (int)x;
breadth = y;
Console.WriteLine(x * y);
}
}
class Program
{
static void Main(string[] args)
{
maths m = new maths(20, 40);
maths k = new maths(12.0, 12);
Console.ReadLine();
}
}Select an option to see the answer and solution.
static void Main(string[] args)
{
int x = 4 ,b = 2;
x -= b/= x * b;
Console.WriteLine(x + " " + b);
Console.ReadLine();
}Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Q100
Open questionclass z
{
public string name1;
public string address;
public void show()
{
Console.WriteLine("{0} is in city{1}", name1, " ", address);
}
}
class Program
{
static void Main(string[] args)
{
z n = new z();
n.name1 = "harsh";
n.address = "new delhi";
n.show();
Console.ReadLine();
}
}Select an option to see the answer and solution.