Monday, August 17, 2015


Persistent Interview question for experience:

Q1. What will be output of following program?
public class Base
    {
        public Base()
        {
            Console.WriteLine("Base");
        }

 

    }

    public class Derived : Base
    {
        public Derived()
        {
            Console.WriteLine("Derived");
        }

 
    }

Public Class Main
{
   static void Main(string[] args)
{
          Derived obj=new Derived()

 }
}


  Ans: Base ,
           Derived

Q2. What will be output of following programs?
 public class Base
    {
        public Base()
        {
            Console.WriteLine("Base");
        }

        public Base(string name)
        {
            Console.WriteLine("Base: " + name);
        }



    }

    public class Derived : Base
    {
        public Derived()
        {
            Console.WriteLine("Derived");
        }

        public Derived(string s)
        {
            Console.WriteLine("Derived: " + s);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {

            Derived d = new Derived("rajesh");
            Console.ReadLine();
        }
    }

Ans: Base
        Derived: rajesh


Q3. What will be output of following program?

 interface IInterface1
    {
        void Show();
    }

    interface IInterface2
    {
        void Show();
    }

    class A : IInterface1, IInterface2
    {
      public void Show()
        {
            throw new NotImplementedException();
        }
    }

A. Error
B. warning
C. No Error
D. Not possible

Ans: No error. It will compile successfully.

No comments:

Post a Comment

Write a program to reverse a string? using System; namespace ConsoleApp1 {     class Program     {         static void Main(string[] args)  ...