A. Inner class B. Anonymous class c. method overloding D. method overriding.
I think ans should be B,D but ans is C. so please tell me what is correct ans.
Amisha Shah.<br />SCJP 1.4
Sandeep Singh Kunwar
Ranch Hand
Joined: Feb 27, 2006
Posts: 52
posted
0
I think "method overloding" is all right, as:
# 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
Arno Reper
Ranch Hand
Joined: Mar 14, 2006
Posts: 286
posted
0
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 ]
rikin shah
Greenhorn
Joined: Apr 17, 2006
Posts: 1
posted
0
visit this link. It also has gr8 discussion of this que. I think both C & D. http://www.javaranch.com
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.
Leonardo Luiz
Amisha Shah
Ranch Hand
Joined: Mar 03, 2006
Posts: 33
posted
0
I think answers are B and D.
overrinding and anonymous claas. because polymorphysm is in play when anonymous classe are involved.
Arno Reper
Ranch Hand
Joined: Mar 14, 2006
Posts: 286
posted
0
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
swapnil paranjape
Ranch Hand
Joined: May 15, 2005
Posts: 125
posted
0
hi
i have read this in one of the textbooks..
there are two types of polymorphism:
1)static polymorphism 2)dynamic or runtime polymorphism
overloading comes under staic polymorphism while overriding comes under runtime polymorphism...
polymorphism means having more than one form so overloading and overriding are part of polymorphism for sure...
please give your comments.
Changchun Wang
Ranch Hand
Joined: Feb 15, 2006
Posts: 83
posted
0
from jsl4
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
paresh mishra
Greenhorn
Joined: Apr 18, 2006
Posts: 1
posted
0
there is 2 type of polymorphism 1: early binding 2: late binding thease are achived through method overloading , method overriding
Vijendra Runwal
Ranch Hand
Joined: Apr 17, 2006
Posts: 52
posted
0
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).
SCJP 1.4,SCWCD
faisal usmani
Ranch Hand
Joined: Jan 14, 2006
Posts: 139
posted
0
Originally posted by swapnil paranjape:
i have read this in one of the textbooks..
there are two types of polymorphism:
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 ]
Swosti Dipan Pal
Ranch Hand
Joined: Sep 23, 2005
Posts: 70
posted
0
Can anyone finally tell what is the correct answer ? It's bit confusing for me now.
Cheers, -Biswa
Thanks<br />-Swosti
Deepak Santhosh
Greenhorn
Joined: Jul 20, 2012
Posts: 1
posted
0
Both method overloading and overriding are examples of polymorphism
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 agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.