Is it possible to do method overloading and overriding at a
time
Answer Posted / shashi
Yes, Is it possible to do method overloading and overriding at a
time
***********************************************
class A
{
void Add(int x, int y)
{
System.out.println("Hello From Class A" + (x+y));
}
}
class B extends A
{
void Add(int x, int y)
{
System.out.println("Hello From Class B" + (x+y));
}
void Add(double x, double y)
{
System.out.println("Hello From Class B" + (x+y));
}
}
class Test
{
public static void main(String ar[])
{
B acv = new B();
acv.Add(100.0,20.0);
acv.Add(10,20);
}
}
| Is This Answer Correct ? | 19 Yes | 0 No |
Post New Answer View All Answers
Is array a class?
What is difference between hashset and hashmap?
What is passed by reference and pass by value ?
When the constructor of a class is invoked?
How can you avoid serialization in child class if the base class is implementing the serializable interface?
What are the 2 types of java programs?
what is anonymous class in java?
What are benefits of java?
How to find the given number is a prime number or not by getting input from the user
Can an object subclass another object?
How do you achieve singleton?
What is native code?
How are java objects passed to a method and what are native methods?
Can we catch more than one exception in single catch block?
What happens if an exception is not handled in a program?