CSharp Programming

CSharp Programming

Interfaces has 14 Questions
Which of the following statements is correct about the C#.NET code snippet given below?
interface IMyInterface
{ 
    void fun1(); 
    int fun2();
}
class MyClass: IMyInterface
{ 
    void fun1()
    { } 
    int IMyInterface.fun2()
    { } 
}

A function cannot be declared inside an interface.
A subroutine cannot be declared inside an interface.
A Method Table will not be created for class MyClass.
The definition of fun1() in class MyClass should be void IMyInterface.fun1().
Which of the following can be declared in an interface?
  1. Properties
  2. Methods
  3. Enumerations
  4. Events
  5. Structures

1, 3
1, 2, 4
3, 5
4, 5
A class implements two interfaces each containing three methods. The class contains no instance data. Which of the following correctly indicate the size of the object created from this class?

12 bytes
24 bytes
0 byte
8 bytes
Which of the following statements is correct about an interface used in C#.NET?

One class can implement only one interface.
In a program if one class implements an interface then no other class in the same program can implement this interface.
From two base interfaces a new interface cannot be inherited.
Properties can be declared inside an interface.
Which of the following statements is correct about Interfaces used in C#.NET?

All interfaces are derived from an Object class.
Interfaces can be inherited.
All interfaces are derived from an Object interface.
Interfaces can contain only method declaration.
Which of the following statements is correct about an interface?

One interface can be implemented in another interface.
An interface can be implemented by multiple classes in the same program.
A class that implements an interface can explicitly implement members of that interface.
The functions declared in an interface have a body.
Which of the following statements are correct about an interface in C#.NET?
  1. A class can implement multiple interfaces.
  2. Structures cannot inherit a class but can implement an interface.
  3. In C#.NET, : is used to signify that a class member implements a specific interface.
  4. An interface can implement multiple classes.
  5. The static attribute can be used with a method that implements an interface declaration.

1, 2, 3
2, 4
3, 5
None of the above.
Which of the following is the correct implementation of the interface given below?
interface IMyInterface
{ 
    double MyFun(Single i);
}

class MyClass{

double MyFun(Single i) as IMyInterface.MyFun

{// Some code    }

}

class MyClass {

MyFun (Single i) As Double

{ // Some code }

}

class MyClass: implements IMyInterface{

double fun(Single si) implements IMyInterface.MyFun()

{ //Some code }

}

class MyClass: IMyInterface{

double IMyInterface.MyFun(Single i)

{ // Some code }

}

Which of the following statements is correct?

When a class inherits an interface it inherits member definitions as well as its implementations.
An interface cannot contain the signature of an indexer.
Interfaces members are automatically public.
To implement an interface member, the corresponding member in the class must be public as well as static.
Which of the following statements are correct about an interface used in C#.NET?
  1. An interface can contain properties, methods and events.
  2. The keyword must implement forces implementation of an interface.
  3. Interfaces can be overloaded.
  4. Interfaces can be implemented by a class or a struct.
  5. Enhanced implementations of an interface can be developed without breaking existing code.

1, 2
1, 4, 5
3, 4
3 only
Which of the following can implement an interface?
  1. Data
  2. Class
  3. Enum
  4. Structure
  5. Namespace

1, 3
2, 4
3, 5
4 only
Which of the following statements is correct about the C#.NET code snippet given below?
interface IMyInterface 
{
    void fun1(); 
    void fun2();
}
class MyClass: IMyInterface
{ 
    private int i; 
    void IMyInterface.fun1()
    { 
        // Some code
    } 
}

Class MyClass is an abstract class.
Class MyClass cannot contain instance data.
Class MyClass fully implements the interface IMyInterface.
The compiler will report an error since the interface IMyInterface is only partially implemented.
Which of the following statements is correct about the C#.NET code snippet given below?
interface IPerson
{ 
    String FirstName
    { 
        get; 
        set;
    }
    String LastName
    {
        get; 
        set;
    }
    void Print(); 
    void Stock(); 
    int Fun(); 
}

Properties cannot be declared inside an interface.
This is a perfectly workable interface.
The properties in the interface must have a body.
Subroutine in the interface must have a body.
Which of the following is the correct way to implement the interface given below?
interface IPerson
{ 
    String FirstName
    {
        get;
        set; 
    } 
}

class Employee : IPerson{

private String str; public String FirstName {

get { return str; }

set { str = value; }

        }

    }

class Employee{

private String str; public String IPerson.FirstName {

get { return str; }

set

{ str = value;}

    }

}

class Employee : implements IPerson{ private String str; public String FirstName {

get { return str; }

set { str = value; }

    }

}

None of the above