Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is mean by overriding in which situation we wil use?

Answer Posted / vikas

Overriding means, In a derived class, if we include same
method name, with same number & types of parameters and
return type as a method already defined in the base class,
then the method is said to be Overridden.

base class:

class Circle {
protected double radius;

public double getArea() {
return Math.PI*radius*radius;
}//this method returns the area of the circle
}

derived class:

class Cylinder extends Circle {

protected double length;

public double getArea() { // method overriden here
return 2*super.getArea()+2*Math.PI*radius*length;
}//this method returns the cylinder surface area
}

Is This Answer Correct ?    7 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How big is a pointer?

985


Where to store local variables?

1036


Which package has light weight components in java programming?

1078


What are the different types of inner classes?

970


What is a lambda expression ? What's its use ?

1049


Differentiate between stringbuffer and stringbuilder in java.

982


Explain restrictions for using anonymous inner classes?

1038


java program with complete 4 oops concepts implemented example

3096


Is 0 an even number?

928


How many bits is a boolean?

1036


Differentiate between nested and inner class in java.

954


What is the epoch date?

957


When can we say that threads are not lightweight process in java?

1079


Which is fastest collection in java?

1002


How you can force the garbage collection?

933