Which two code segments should you use?

You are developing an application that includes the following code segment:

You need to implement both Start() methods in a derived class named UseStart that uses
the Start() method of each interface.
Which two code segments should you use? (Each correct answer presents part of the
solution. Choose two.)

You are developing an application that includes the following code segment:

You need to implement both Start() methods in a derived class named UseStart that uses
the Start() method of each interface.
Which two code segments should you use? (Each correct answer presents part of the
solution. Choose two.)

A.
Option A

B.
Option B

C.
Option C

D.
Option D

E.
Option E

F.
Option F

Explanation:
B:
* Implementing Multiple Interfaces
A class can implement multiple interfaces using the following syntax:
C#
public class CDAndDVDComboPlayer : ICDPlayer, IDVDPlayer
If a class implements more than one interface where there is ambiguity in the names of
members, it is resolved using the full qualifier for the property or method name. In other
words, the derived class can resolve the conflict by using the fully qualified name for the
method to indicate to which interface it belongs
* In C#, both inheritance and interface implementation are defined by the : operator,
equivalent to extends and implements in Java. The base class should always be leftmost in
the class declaration.



Leave a Reply 9

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


delfigaro

delfigaro

The answer for this question is wrong;

It should be like this SO answer explains: http://stackoverflow.com/a/2371203

So the answer should be:

Option C because it explicitly implements the two Start functions of both interfaces.
Option D because we need to type cast the starter object to the interface that we want to use the implementation for.

My'nD

My'nD

And same as 175 kind of question as 175.
Answer is CD.

Shubham Mishra

Shubham Mishra

I think it should be B & D

PaulC

PaulC

CD

C – because you cant add access modifier Public to explicitly implemented interface
D – you need to Cast interface to call the method.

It is quite usual way to hide certain functionality on method as you call it thru interface only

keyur

keyur

CD correct and confirm code.