G
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
SCJP6.0,My blog Ranchers from Delhi
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Wouter Oet wrote:Why would polymorphism not apply to overloaded methods and generics??
Overloaded methods in combination with polymorphism:
SCJP6.0,My blog Ranchers from Delhi
Wouter Oet wrote:
Generics in combination with polymorphism:
SCJP6.0,My blog Ranchers from Delhi
Shanky Sohar wrote:Just to inform you that overloading happens when we change the argument of the methods
but here we are overridding both the test methods in Bar class
public void test(Object o)
public void test(Integer o)
So that why here polymorphism applies here
Shanky Sohar wrote:No,it is a method overridden,because polymorphism applies only to the Base type not to a generic type.
Here you are overriding the test method.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
SCJP6.0,My blog Ranchers from Delhi
SCJP6.0,My blog Ranchers from Delhi
l polymorphism has to be at run time. Think of this scenario, Java has exposed JDBC drivers interface and you load the driver class at runtime. Using the same code you can connect to any JDBC compliant database where the actual database to be connected may be supplied by user at runtime. How such a functionality can be supported at compile time?
SCJP6.0,My blog Ranchers from Delhi
I agree with that but that is not what you said. You just said that polymorphism doesn't apply to overloaded methods. But what you probably meant was that polymorphism doesn't apply to overloaded methods that don't override methods in the parent class.Shanky Sohar wrote:main point is that polymorphism doesn't determine which overloaded version is called..
polymorphism does come into play when the decision is about which overridden method is called.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |