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


Please Help Members By Posting Answers For Below Questions

What is the purpose of the finalize() method?

920


Can I declare class as static or private?

729


Why string is a class?

703


Where and how can you use a private constructor?

715


Why is it called buffering?

800






What is the purpose of using break in each case of switch statement?

749


Can a constructor be private and how are this() and super() method used with constructor?

715


What are the methods of object class ?

750


What is Session reduplication and how its done?

1751


What is replacefirst in java?

746


Which language is java?

733


What are different types of constants?

699


What is immutable class in java?

684


What is the purpose of void?

716


Explain the selection sort algorithm?

830