wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Overloading and type conversion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Overloading and type conversion" Watch "Overloading and type conversion" New topic
Author

Overloading and type conversion

Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1533
I have a method CALL which passes a character as an argument, and the class defines two methods of same name one with argument of type character and another of type int. Which method will be called at runtime, the one with int or the one with character??


Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Vijay Gade
Ranch Hand

Joined: Jul 04, 2005
Posts: 81
The one with char.
achayya matta
Ranch Hand

Joined: Oct 27, 2005
Posts: 111
Ya Akhil,
in such cases "The Most Specific Method Is Chosen"
Read JLS2.0 for more details.Hope it helps u!
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1533
thanks vijay and ashok
Ost. Ken
Greenhorn

Joined: Aug 24, 2005
Posts: 4
hi hope this will help



the result is "int"
[ November 23, 2005: Message edited by: Ost. Ken ]
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
I thought your example was a hoot, Ost. Ken,
but I fear that many here will not see your
slight-of-hand and misunderstand things.

We all agree that if you write the second
test() method to take a parameter of type
char instead of Character that the result
will not be "int", right?
[ November 23, 2005: Message edited by: Brian Cole ]

bitguru blog
Ost. Ken
Greenhorn

Joined: Aug 24, 2005
Posts: 4
Hi,
if Character change to char result will not be "int".

sry about my bad sample ....
i think the correct answers was already replied by vijay and ashok

My purpose is to show Autoboxing/Unboxing will not use in this case(but i didn't tell that my sample is for 5.0 ...very very sry about that).

thank you for ur comment Brian ^^
AbhiRam Kalyan
Greenhorn

Joined: Oct 31, 2005
Posts: 25
Hi,
what "The Most Specific Method Is Chosen" in the sense.
any body please explain little bit more


Sasikanth
 
jQuery in Action, 2nd edition
 
subject: Overloading and type conversion