C# QUIZ 6

2
Created on By Sirjana GhimireAcharya

C# Quiz 6

1 / 10

1. Which of the following options define the correct way of implementing an interface data by the class employee?

2 / 10

2. Which of the following Access specifiers can be used for an interface?

3 / 10

3. Which of the following statements is correct for the below code snippet?

interface A
{
void func1();
int func2();
}
class B : A
{
void func1()
{
}
int A.func2()
{
}
}

4 / 10

4. Which of the following statements is correct for the below code snippet?

interface A
{
String FirstName
{
get;
set;
}
String LastName
{
get;
set;
}
void print();
void assign();
int func();
}

5 / 10

5.What will be the output of the following code snippet?
interface A
{
void func(int i);
}
class B1 : A
{
public int x;
public void func(int i)
{
x = i * i;
}
}
class B2 : A
{
public int x;
public void func(int i)
{
x = i / i;
}
}
class Program
{
public static void Main(string[] args)
{
B1 b1 = new B1();
B2 b2 = new B2();
b1.x = 0;
b2.x = 0;
b1.func(2);
b2.func(2);
Console.WriteLine(b1.x + " " + b2.x);
Console.ReadLine();
}
}

6 / 10

6. Which of the following keywords can be used to access a member of the base class from derived class?

7 / 10

7.What will be the output of the following code snippet?
class baseSample
{
int i = 10;
int j = 20;
public void print()
{
Console.WriteLine("inside base method ");
}
}
class derivedSample : baseSample
{
public int s = 30;
}
class Program
{
static void Main(string[] args)
{
derivedSample d = new derivedSample();
Console.WriteLine("{0}, {1}, {2}", d.i, d.j, d.s);
d.print();
Console.ReadLine();
}
}

8 / 10

8.What will be the size of the object created in the given code snippet?
class baseSample
{
private int a;
protected int b;
public int c;
}
class derivedSample : baseSample
{
private int x;
protected int y;
public int z;
}
class Program
{
static Void Main(string[] args)
{
derivedSample d = new derivedSample();
}
}

9 / 10

9. What will be the of the following code snippet?
class baseSample
{
public baseSample()
{
Console.WriteLine("THIS IS BASE CLASS constructor");
}
}
public class derivedSample : baseSample
{

}
class Program
{
static void Main(string[] args)
{
derivedSample d = new derivedSample();
Console.ReadLine();
}
}

10 / 10

10. What will be the output of the following code snippet?
class Baseclass
{
public void fun()
{
Console.Write("Base class" + " ");
}
}
class Derived1: Baseclass
{
new void fun()
{
Console.Write("Derived1 class" + " ");
}
}
class Derived2: Derived1
{
new void fun()
{
Console.Write("Derived2 class" + " ");
}
}
class Program
{
public static void Main(string[ ] args)
{
Derived2 d = new Derived2();
d.fun();
}
}

Your score is

The average score is 30%

0%