GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Microsoft  >  ASP.NET 2.0

 Print  |  
Question:  What is diff. between abstract class and an interface? * What is shadowing? * Diff between Overriding and overloading



October 10, 2005 16:45:36 #6
 Ranjit Srinivasan CRM Expert  Member Since: October 2005    Total Comments: 18 

RE: What is diff. between abstract class and an interf...
 

Over Loading and Overriding

In a class if two method is having the same name and different signature,its known as overloading in Object oriented concepts.

For eg  Take the case of a Shape Class. having  a method with a name DrawShape();

This method has two definitins with different parameters.

public void DrawShape(int x1, int y1,int x2,int y2)
{
 // draw a rectangle.
}

public void DrawShape(int x1,int y1)
{

// draw aline.
}

Overriding means, to give a specific definition by the derived class for a method implemented in the base class.

For eg.



Class Rectangle
{

   publc void DrawRectangle()
  {
    // this method will draw a rectangle.
  }

}


Class RoundRectangle : Rectanlge
{

  public void DrawRectangle()
  {

      //Here the DrawRectangle() method is overridden in the
     // derived class to draw a specific implementation to the
     //derived class, i.e to draw a rectangle with rounded corner.

  }
}

     

 

Back To Question