HOTSPOT
A developer designs an interface that contains the following code:
For each of the following statements, select Yes if the statement is true. Otherwise, select No.
Hot Area:
HOTSPOT
A developer designs an interface that contains the following code:
For each of the following statements, select Yes if the statement is true. Otherwise, select No.
Hot Area:
Answer is Yes-Yes-No.
Method1 throws NotImplemented exception regardless of class.
And class2 uses explicit interface implementation, not implicit
The question is about casting not calling Method1()
Answer is correct.
The correct answer should be:
No, Yes, No
Explanation:
Class2 someInstance = new Class2();
someInstance.Method1() // this code don’t compiled because Class2 explicit implement Method1. So we could invoke this method only after cast it instance into INewInterface.
This is correct, because INewInterface is explicitly implemented and invoking that method requires casting of the instance of that class to INewInterface. Class1 is inheriting from class2 so once casted exception will be thrown. If method1 was implicitly implemented, the instances of either class could invoke the method.
An “explicit” implementation method has no acces modifiers. The answer is correct
Yes, no, Yes, when specifying the name of the interface as shown in the code sample that is called an implicit interface implementation
You are wrong. See here: http://www.c-sharpcorner.com/UploadFile/8911c4/implicit-and-explicit-interface-examples/