System.out.println("super class version of getNumber");
Integer k = (Integer)i;
return k; }
In the subclass
public int getNumber (Integer i){
System.out.println("subclass version of getNumber"); return 1; }
In the main method
superclass mn = new Main();
mn.getNumber(5);
I get
super class version of getNumber
which means it has not been overridden. SO is the following a valid statement?
"A method can only be considered overridden if the signatures match exactly, an event in which the the signatures pass an is a relationship with the parents method parameters, it is still considered an overload and not an override"
"A method can only be considered overridden if the signatures match exactly,/QB]
Regarding above , its true for method parameters, but you can change the return type to be more specific. That is a sub class of the actual return type can be given in the overridden method.
As I understand it these are overloaded methods and sice you are passing an int value the it will be wrapped to Integer and it will invoke the Integer method. if no Integer argument exist it will widen to Number and invoke the superclass method.
Trust me I'm preparing for the SCJP and practiced this a few times.