PrepAway - Latest Free Exam Questions & Answers

4 Comments on “A developer designs an interface that contains the following code:

  1. J says:

    YES,YES,NO

    public class Program
    {
    public static void Main(string[] args)
    {
    //Class2 class2 = new Class2();
    //((INewInterface)class2).Method1();

    Class1 class1 = new Class1();
    ((INewInterface)class1).Method1();
    }
    }

    public class Class1 : Class2{}
    public class Class2 : INewInterface{
    void INewInterface.Method1(){
    throw new NotImplementedException();
    }
    }
    public interface INewInterface{
    void Method1();
    }




    2



    3
    1. ivannathan says:

      2nd question – If you cast class1 to interface, the exceptions is thrown.
      the answer is NO, because class1 is inherited from class2, which uses interface. In other words, class1 also has interface




      0



      1

Leave a Reply