Interface

0%

In C#, interface can contain

Correct! Wrong!

What is correct statement about Interfaces?

Correct! Wrong!

C# support partial implementation of interfaces

Correct! Wrong!

We can use access specifier in interface?

Correct! Wrong!

What is the output of below program?
class Program
{
static void Main()
{
IBonus salary = new Salary();
((IOverTime)salary).Add();
Console.ReadLine();
}
}

public interface IBonus
{
void Add();
}

public interface IOverTime
{
void Add();
}

public class Salary : IBonus, IOverTime
{
void IBonus.Add()
{
Console.WriteLine("Added Bonus into salary.");
}

void IOverTime.Add()
{
Console.WriteLine("Added Over Time into salary.");
}
}

Correct! Wrong!

Can we create an instance of Interface?

Correct! Wrong!

Is below source code correct?
public interface IBonus
{
void Add();
void SpecialBonus();
}



public class Salary : IBonus
{
void IBonus.Add()
{
Console.WriteLine("Added Bonus into salary.");
}
}

Correct! Wrong!

Is below interface declaration is correct?
public interface IBonus
{
int x = 10;
}

Correct! Wrong!

Correct, we cannot declare a variable in the interface.

Which is correct option about interface?

Correct! Wrong!

What is the output of below program?
class Program
{
static void Main()
{
IBonus salary = new Salary();
salary.Print();
Console.ReadLine();
}
}

public interface IBonus
{
void Add();
}

public class Salary : IBonus
{
void IBonus.Add()
{
Console.WriteLine("Added Bonus into salary.");
}

void Print()
{
Console.WriteLine("Salary is added");
}
}

Correct! Wrong!

Interface
Result
Beginner!
You need to work hard, here is a tutorial on an Interface
Result
Intermediator!
You are good but there is work to be done, here is a tutorial on an Interface
Pro!
You are excellent, here is a tutorial on an Interface

Leave a Reply

Your email address will not be published. Required fields are marked *