Which keyword is used for correct implementation of an interface in C# net?

C# multiple choice questions on interface introduction in C# Programming Language.

1. Which statement correctly defines Interfaces in C#.NET?
a] Interfaces cannot be inherited
b] Interfaces consists of data static in nature and static methods
c] Interfaces consists of only method declaration
d] None of the mentioned

Answer: d
Clarification: Leaving all options only option ‘a’ is correct as interfaces can be inherited i.e inheritance can be performed in csharp .net.

2. Which of the following cannot be used to declare an interface correctly?
a] Properties
b] Methods
c] Structures
d] Events

Answer: c
Clarification: None.

3. A class consists of two interfaces with each interface consisting of three methods. The class had no instance data. Which of the following indicates the correct size of object created from this class?
a] 12 bytes
b] 16 bytes
c] 0 bytes
d] 24 bytes

Answer: d
Clarification: None.

4. Which of the following statements correctly define about the implementation of interface?
a] The calls to implementation of interface methods are routed through a method table
b] A class which implements an interface can explicitly implement members of that interface
c] One interface can be implemented in another interface
d] None of the mentioned

Answer: a
Clarification: None.

5. Select the correct statement among the given statements?
a] One class could implement only one interface
b] Properties could be declared inside an interface
c] Interfaces cannot be inherited
d] None of the mentioned

Answer: b
Clarification: None.

6. Which keyword is used for correct implementation of an interface in C#.NET?
a] interface
b] Interface
c] intf
d] Intf

Answer: a
Clarification: None.

7. Choose the statements which makes interface different from classes?
a] Unlike classes, interfaces consists of only declaration but not implementation
b] Interfaces cannot be used directly like classes to create new objects
c] Interfaces consists of declaration of methods, properties events and type definitions
d] All of the mentioned

Answer: d
Clarification: None.

8. Which of the following is the correct way of implementing an interface addition by class maths?
a] class maths : addition {}
b] class maths implements addition {}
c] class maths imports addition {}
d] none of the mentioned

Answer: a
Clarification: None.

9. Does C#.NET support partial implementation of interfaces?
a] True
b] False
c] Can’t Say
d] None of the mentioned

Answer: b
Clarification: Interface is a behaviour. It represents a protocol or a contract of sorts. Hence, it is impossible to implement an interface partially.

10. Select the correct implementation of the interface which is mentioned below.

  1. interface a1
  2. {
  3.     int fun[int i];
  4. }

a]

  1.  class a
  2.  {
  3.      int fun[int i] as a1.fun
  4.      {
  5.      }
  6.  }

b]

  1. class a: implements a1
  2. {
  3.     int fun[int i]
  4.     {
  5.     }
  6. }

c]

  1.  class a: a1
  2.  {
  3.      int a1.fun[int i]
  4.      {
  5.      }
  6.  }

d] None of the mentioned

Answer: c
Clarification: None.

11. Which of these can be used to fully abstract a class from its implementation?
a] Objects
b] Packages
c] Interfaces
d] None of the Mentioned

Answer: c
Clarification: None.

12. Access specifiers which can be used for an interface are?
a] Public
b] Protected
c] Private
d] All of the mentioned

Answer: a
Clarification: Access specifier of an interface is either public or none. When no access specifier is specified then only default access specifier is used due to which interface is available only to other members of the package in which it is declared, when declared public it can be used by any code declared anywhere in the class area.

Which of the following is used for correct implementation of an interface in C?

6. Which keyword is used for correct implementation of an interface in C#.NET? Explanation: None.

Which keyword is used for correct implementation of an interface in C has net?

In C#, an interface can be defined using the interface keyword. An interface can contain declarations of methods, properties, indexers, and events.

Which keyword is used for correct implementation of an interface?

To access the interface methods, the interface must be "implemented" [kinda like inherited] by another class with the implements keyword [instead of extends ]. The body of the interface method is provided by the "implement" class.

Which of the following types can implement interfaces?

There are primarily 5 java types that can implement interfaces that are listed below which we are going to explore over later to depth as follows:.
Java Class..
Java Abstract Class..
Java Nested Class..
Java Enum..
Java Dynamic Proxy..

Chủ Đề