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
Can a constructor be private and how are this() and super() method used with constructor?
Why we do exception handling in java and how many types of exceptions are there?
Explain about exception propagation?
Explain jdk, jre and jvm?
What is classpath?
What is method and methodology?
What is instanceof keyword?
Explain purpose of sleep() method in java?
Why main function is static?
List down the methods and interfaces of collection class in java.
Which eclipse is best for java?
How will you calculate the depth of a binary tree if the tree contains 15 nodes?
When parseint method can be used?
Can we override private method?
Is set sorted in java?