-5

I have a method in super class

protected int discount(int amount) 

and a method in subclass

protected int discount(int amount1) 

Is the method in subclass is going to overload or not???

Rey Libutan
  • 5,226
  • 9
  • 42
  • 73
Ali Ansari
  • 219
  • 3
  • 14
  • 8
    This question appears to be off-topic because OP can easily test this in any electric device that has a compiler. – Maroun Mar 06 '14 at 08:48
  • 1
    @AliAnsari You probably mean `override`. Please do read the difference between `override` and `overload`, e.g. in (http://stackoverflow.com/questions/12374399/difference-between-method-overloading-and-overriding-in-java) – wolfrevo Mar 06 '14 at 08:52

2 Answers2

0

No, method overloading works if you have different type or number of arguments. variable names don't matter

Raghvendra Singh
  • 1,775
  • 4
  • 26
  • 53
0

(Excepting your misuse of terminology.) In Java, if you have a function in a sub-class that is identical in name, parameters and (loosely), the return type to a function in the super-class then objects of the sub-class type will use the function in the sub-class. This is called function overriding. (And in Java, unlike C++, is automatic).

(Function overloading is used to describe functions that have identical names but differing parameters.)

Bathsheba
  • 231,907
  • 34
  • 361
  • 483