C# QUIZ 7

2
Created on By Sirjana GhimireAcharya

C# Quiz 7

1 / 10

1. What will be the output of the following code snippet?
public class emp
{
public static int age = 40;
public static int salary = 25000;

}
public class record :emp
{
new public static int salary = 90000;
static void Main(string[] args)
{
Console.WriteLine(emp.age + " " + emp.salary + " " + salary);
}
}

2 / 10

2. Which of the following keyword, enables to modify the data and behavior of a base class by replacing its member with a new derived member?

3 / 10

3. Which of the following statements are correct for C# language?

4 / 10

4. Which of the following keywords is used to refer base class constructor to subclass constructor?

5 / 10

5.What will be the output of the following code snippet?
class sample
{
int i;
public sample(int x)
{
i = x;
Console.WriteLine("Tech");
}
}
class derived : sample
{
public derived(int x) :base(x)
{
Console.WriteLine("Beamers");
}
}
class Program
{
static void Main(string[] args)
{
derived k = new derived(12);
Console.ReadLine();
}
}

6 / 10

6.What will be the output of the following code snippet?
class sample
{
int i;
public sample(int num)
{
num = 12;
int j = 12;
int val = num * j;
Console.WriteLine(val);
}
}
class sample1 : sample
{
public sample1(int a) :base(a)
{
a = 13;
int b = 13;
Console.WriteLine(a + b);
}
}
class sample2 : sample1
{
public sample2(int k) :base(k)
{
k = 24;
int o = 6 ;
Console.WriteLine(k /o);
}
}
class Program
{
public static void Main(string[] args)
{
sample2 t = new sample2(10);
Console.ReadLine();
}
}

7 / 10

7.What will be the output of the following code snippet?
class sample
{
static sample()
{
int num = 8;
Console.WriteLine(num);
}
public sample(int a)
{
int val = 10;
Console.WriteLine(val);
}
}
class Program
{
static void Main(string[] args)
{
sample s = new sample(100);
Console.ReadLine();
}
}

8 / 10

8. Which of the following options represents the type of class which does not have its own objects but acts as a base class for its subclass?

9 / 10

9. Which of the following represents a class that inherits an abstract class but it does not define all of its functions?

10 / 10

10.What will be the output of the following code snippet?
namespace TechBeamers
{
public abstract class sample
{
public int i = 7;
public abstract void print();
}
class sample1: sample
{
public int j;
public override void print()
{
Console.WriteLine(i);
Console.WriteLine(j);
}
}
class Program
{
static void Main(string[] args)
{
sample1 obj = new sample1();
sample obj1 = new sample1();
obj.j = 1;
obj1.i = 8;
obj.print();
Console.ReadLine();
}
}
}

Your score is

The average score is 30%

0%