Is it possible to do method overloading and overriding at a
time

Answers were Sorted based on User's Feedback



Is it possible to do method overloading and overriding at a time..

Answer / 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

Is it possible to do method overloading and overriding at a time..

Answer / rameshreddy

No it is not possible at a time. Method overloading is
possible in the same class is possible. But method
overriding is possible its subclass only possible

Is This Answer Correct ?    18 Yes 6 No

Is it possible to do method overloading and overriding at a time..

Answer / sathishkumar.m

class A
{
int c;
void add()
{
System.out.println("hai");
}
void add(int b)
{
c=b;
System.out.println("value of b:"+c);
}
}
class B
{
int e;
void add(int d)
{
System.out.println("value of d:"+e);
}
}
class Demo
{
public static void main(String aa[])
{
A o1=new B();
o1.add();
}
}

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More Core Java Interview Questions

What is the frontend and backedn in Java?

3 Answers   TCS,


Is minecraft 1.15 out?

0 Answers  


What is difference between overloading and overriding?

2 Answers   Accenture,


What is difference between ++ I and I ++ in java?

0 Answers  


where do we use init()

2 Answers  






What is adapter in java?

0 Answers  


How do you sort in descending order in java using collections sort?

0 Answers  


What are accessor methods in java?

0 Answers  


What type of variable is gender?

0 Answers  


What does the string method compareto () do?

0 Answers  


What is java and its types?

0 Answers  


I was asked to draw the class diagram for the below scenario which should obey OOPS concept. A Portal is to be developed for a school , which has 3 main divisions viz , Education , Admin & Trust. Each division has 2 sub divisions Kinder Garden & Higer Secondary.

3 Answers   Amtek, Huawei,


Categories