logo

CuriousTab

CuriousTab

Interfaces problems


  • 1. Which of the following is the correct implementation of the interface given below?

    interface IMyInterface
    { 
        double MyFun(Single i);
    }

  • Options
  • A.
    class MyClass
    {
        double MyFun(Single i) as IMyInterface.MyFun
        {
            // Some code
        }
    }
  • B.
    class MyClass 
    {
        MyFun (Single i) As Double
        {
            // Some code
        } 
    }
  • C.
    class MyClass: implements IMyInterface
    {
        double fun(Single si) implements IMyInterface.MyFun()
        {
            //Some code
        } 
    }
  • D.
    class MyClass: IMyInterface
    {
        double IMyInterface.MyFun(Single i)
        {
            // Some code
        } 
    }
  • Discuss
  • 2. Which of the following statements is correct about an interface used in C#.NET?

  • Options
  • A. If a class implements an interface partially, then it should be an abstract class.
  • B. A class cannot implement an interface partially.
  • C. An interface can contain static methods.
  • D. An interface can contain static data.
  • E. Multiple interface inheritance is not allowed.
  • Discuss
  • 3. Which of the following is the correct way to implement the interface given below?

    interface IPerson
    { 
        String FirstName
        {
            get;
            set; 
        } 
    }

  • Options
  • A.
    class Employee : IPerson
    {
        private String str; 
        public String FirstName
        {
            get
            { 
                return str;
            } 
            set
            { 
                str = value;
            } 
        } 
    }
  • B.
    class Employee
    {
        private String str;
        public String IPerson.FirstName
        { 
            get
            { 
                return str;
            } 
            set
            { 
                str = value;
            } 
        } 
    }
  • C.
    class Employee : implements IPerson
    {
        private String str; 
        public String FirstName
        { 
            get
            { 
                return str;
            } 
            set
            {
                str = value; 
            } 
        } 
    }
  • D. None of the above
  • Discuss
  • 4. Which of the following statements is correct about an interface used in C#.NET?

  • Options
  • A. One class can implement only one interface.
  • B. In a program if one class implements an interface then no other class in the same program can implement this interface.
  • C. From two base interfaces a new interface cannot be inherited.
  • D. Properties can be declared inside an interface.
  • E. Interfaces cannot be inherited.
  • Discuss
  • 5. 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.

  • Options
  • A. 1, 2, 3
  • B. 2, 4
  • C. 3, 5
  • D. None of the above.
  • Discuss

First 2