# In computer science, polymorphism is the idea of allowing the same code to be used with different classes of data (which classes in typed languages correspond to types), resulting in more general and abstract implementations. en.wikipedia.org/wiki/Polymorphism_(computer_science)
# In object-oriented programming theory, polymorphism is the ability of objects belonging to different types to respond to methods of the same name, each one according to the right type-specific behavior. The programmer (and the program) does not have to know the exact type of the object in advance, so this behavior can be implemented at run time (this is called late binding or dynamic binding). en.wikipedia.org/wiki/Polymorphism_(object-oriented_programming)
The only confusion may be on overloading and overriding, i would like to hear more clarifications.
that's an overloading...it's not an example of polymorphism Only anonymous class is a real exemple of polymorphism...because you reach the anonymous object throug a superclass reference. Overiding is about inheritance... i hope it help a bit arno [ April 17, 2006: Message edited by: Arno Reper ]
The man who makes no mistakes does not usually make anything<br /> <br />>>> SCJP 5.0 >> SCJD B&S <<< In progress
Joined: Mar 14, 2006
a tip: you shouldn't use wikipedia to study for SCJP, its not complete enough and it could create misunderstanding. The best way for learning scjp is the ...well known and famous K&B books lol arno ps : i like wikipedia but not for studying a certification like scjp
I would go for B C and D. B because anon classes will subclass an existing class or implement an interface and C , D because inheritance is a form of polymorphism and both overloading and overriding can be considered as forms of polymorphism.
are you sure? b,c,d? i 'd go for the B only... arno ps : read k&b books pg 154 " Polymorphism applies to overriding not to overloading"...c is not ok d maybe but... [ April 17, 2006: Message edited by: Arno Reper ]
Polymorphism is provided by method overriding, when a method is invoked using a super class reference variable (or interface). So any different implementations, provided by sub classes, can be invoked like a unique method. It is closely related with inheritance. Unlike, overloading is not dependent of inheritance and is not related with Polymorphism. It allows us to use the same method name with different arguments.
Sorry for my poor English.
Joined: Mar 03, 2006
I think answers are B and D.
overrinding and anonymous claas. because polymorphysm is in play when anonymous classe are involved.
Joined: Mar 14, 2006
at least,i 'll say ( write ) its certainly not a and c ... b for sure, d its about inheritance...who polymorphism is about so maybe d also. arno
polymorphism, meaning that an object of a given class can have multiple forms, either as its own class or as any class it extends. The new class is a subclass or extended class of the class it extends; the class that is extended is its superclass.
hence i think polymorphism effect on object other than methods or others
The answer is c & d. method overloading and method overriding are the types of polymorphism. Method Overloading is static polymorphism and Method Overriding is Dynamic Polymorphism. Polymorphism is nothing but one thing existing in different forms. That's what we do with method overloading i.e same function name with different types and/or number of arguments and in case of method overriding it's the same function name(present in both base as well as derived class) but execution depends on who(object of base class or derived class) called the function(object reference used).
1)static polymorphism 2)dynamic or runtime polymorphism
hello swapnil ,
I agree with you polymorphism are of two types static(compile time) and dynamic (run time), function overloading is an example of static polymorphism , where as overriding functions of base class in a derived class is an example of runtime polymorphism. [ April 18, 2006: Message edited by: faisal usmani ]
Well in the orthodox way B, C and D are correct. Explanation similar to Pritish. But the main point here is what do you understand by "Polymorphism". What exactly is poly-morphed? The behavior of an object is poly-morphed which can happen if the compiler resolves it or its resolved at run time. I wouldn't say compile time resolution is a great example of polymorphism as the behaviour is bound and cannot change after that.
[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com