Saturday, November 5, 2011

Q1.  What is the output if code snippet 3 is executed (consider definitions of code snippet 1 and code snippet 2 too to find your answer)?

interface IA


{
        void Goto();
}

class mybase

{
       void Goto()
        {
               Console.WriteLine("inside mybase constructor.");
        }
}

What is the output of the following code block ?

class  myderivedmybaseIA
{
        
}

a) Does it compiles successfully? or Does it throw any error?
b) Do we need to provide definition of method Goto() in class A()?

Q2. Do we need to define method named Goto() in class "myderived"? or that is not needed ? consider following code?



interface IA
{
        void Goto();
}
interface IB
{
        void Goto();
}
class  mybase
{
        public void Goto()
        {
            Console.WriteLine("inside mybase constructor.");
        }
}
class  myderivedmybase ,IA
{
       //    Does this code compile and run successfully?      
}


a)  Does this code compile and run successfully?      
b) What happens if the keyword "public" is removed from Goto() method defination in "mybase" class?
c) What happens when in interface "IB", the signature of the method "void Goto()" is changed to some other say "int Goto()" keeping everything same? Does "myderived" is compiled successfully or it throws any error?










No comments: