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
Write a function for palindrome and factorial and explain?
Tell me are there implementations for sorting and searching in the java libarary?
How do you escape json?
Who developed java?
Is it possible to compare various strings with the help of == operator?
Do we have pointers in java?
we have syntax like for(int var : arrayName) this syntax is to find whether a number is in the array or not.but i want to know how to find that number's location.
What is a static class in java?
Where import statement is used in a java program?
What is the default size of load factor in hashing based collection?
Is class forname reflection?
What is java util collection?
Explain about procedural programming language or structured programming language and its features?
Write a program to search a number in the given list of numbers.
What is the main use of java?