logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Interfaces Comments

  • Question
  • Which of the following statements is correct?


  • Options
  • A. When a class inherits an interface it inherits member definitions as well as its implementations.
  • B. An interface cannot contain the signature of an indexer.
  • C. Interfaces members are automatically public.
  • D. To implement an interface member, the corresponding member in the class must be public as well as static.

  • Correct Answer
  • Interfaces members are automatically public. 


  • Interfaces problems


    Search Results


    • 1. 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?

    • Options
    • A. 12 bytes
    • B. 24 bytes
    • C. 0 byte
    • D. 8 bytes
    • E. 16 bytes
    • Discuss
    • 2. Which of the following statements is correct about Interfaces used in C#.NET?

    • Options
    • A. All interfaces are derived from an Object class.
    • B. Interfaces can be inherited.
    • C. All interfaces are derived from an Object interface.
    • D. Interfaces can contain only method declaration.
    • E. Interfaces can contain static data and methods.
    • Discuss
    • 3. It is compulsory for all classes whose objects can be thrown with throw statement to be derived from System.Exception class.

    • Options
    • A. True
    • B. False
    • Discuss
    • 4. Which of the following statements are correct about exception handling in C#.NET?

      1. try blocks cannot be nested.
      2. In one function, there can be only one try block.
      3. An exception must be caught in the same function in which it is thrown.
      4. All values set up in the exception object are available in the catch block.
      5. While throwing a user-defined exception multiple values can be set in the exception, object.

    • Options
    • A. 1 only
    • B. 1 and 2 only
    • C. 3 only
    • D. 4 and 5 only
    • E. All of the above
    • Discuss
    • 5. Which of the following statements are correct about the exception reported below?
      Unhandled Exception: System.lndexOutOfRangeException: Index was outside the bounds of the array: at CuriousTabConsoleApplication.MyProgram.SetVal(Int32 index, Int32 val) in D:\Sample\CuriousTabConsoleApplication\MyProgram.cs:line 26 at CuriousTabConsoleApplication.MyProgram.Main(String[] args) in D:\Sample\CuriousTabConsoleApplication\MyProgram.cs:line 20

      1. The CLR failed to handle the exception.
      2. The class MyProgram belongs to the namespace MyProgram.
      3. The function SetVal() was called from Main() in line number 20.
      4. The exception occurred in line number 26 in the function SetVal()
      5. The runtime exception occurred in the project CuriousTabConsoleApplication.

    • Options
    • A. 1 only
    • B. 1 and 2 only
    • C. 3, 4 and 5 only
    • D. All of the above
    • E. None of the above
    • Discuss
    • 6. Which of the following can implement an interface?

      1. Data
      2. Class
      3. Enum
      4. Structure
      5. Namespace

    • Options
    • A. 1, 3
    • B. 2, 4
    • C. 3, 5
    • D. 4 only
    • Discuss
    • 7. Which of the following statements is correct about an interface?

    • Options
    • A. One interface can be implemented in another interface.
    • B. An interface can be implemented by multiple classes in the same program.
    • C. A class that implements an interface can explicitly implement members of that interface.
    • D. The functions declared in an interface have a body.
    • Discuss
    • 8. 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()
          { } 
      }

    • Options
    • A. A function cannot be declared inside an interface.
    • B. A subroutine cannot be declared inside an interface.
    • C. A Method Table will not be created for class MyClass.
    • D. MyClass is an abstract class.
    • E. The definition of fun1() in class MyClass should be void IMyInterface.fun1().
    • Discuss
    • 9. 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.

    • Options
    • A. 1, 2
    • B. 1, 4, 5
    • C. 3, 4
    • D. 3 only
    • Discuss
    • 10. Which of the following can be declared in an interface?

      1. Properties
      2. Methods
      3. Enumerations
      4. Events
      5. Structures

    • Options
    • A. 1, 3
    • B. 1, 2, 4
    • C. 3, 5
    • D. 4, 5
    • Discuss


    Comments

    There are no comments.

Enter a new Comment