www.evidhyashala.com provides free free mock test , free online exam , online exam free test series , online exam free , Online Test Exam Series , free exam papers past papers , online exam form ,Online Test Series for Exam Prep. Free Mock Tests - for All govt jobs. Bank PO, Clerk, SSC CGL, CHSL, JE, GATE, Insurance, Railways, IBPS RRB, SBI, RBI, IPPB, BSNL TTA

Sponser Link

know more info pls click here

What is the ouput of the following program?-intervew18022012

using System;
namespace Nested
{
  class ContainerClass
  {
    public ContainerClass()
    {
      Console.WriteLine("I am a container class");
    }

    public class InnerClass : ContainerClass
    {
      public InnerClass()
      {
        Console.WriteLine("I am an inner class");
      }
    }
  }

  class DemoClass : ContainerClass.InnerClass
  {
    public DemoClass()
    {
      Console.WriteLine("I am a Demo class");
    }
    public static void Main()
    {
      DemoClass DC = new DemoClass();
    }
  }
}

Output:
I am a container class
I am an inner class
I am a Demo class

The above program has used the concepts of inheritance and nested classes. The ContainerClass is at the top in the inheritance chain. The nested InnerClass derives from outer ContainerClass. Finally the DemoClass derives from nested InnerClass. As all the 3 classes are related by inheritance we have the above output.

0 comments:

Popular Posts