aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes scjp question required Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "scjp question required" Watch "scjp question required" New topic
Author

scjp question required

PETER CARTER
Ranch Hand

Joined: Aug 28, 2004
Posts: 70
public class test1 {
void c(int i){
System.out.println("int");
}
void c(String s){
System.out.println("String");
}
public static void main(String[] args) {
test1 t=new test1();
char ch='p';
t.c(ch);
}
}
Why the result is :
int ??
Thanks!!
Gil Li
Greenhorn

Joined: May 27, 2004
Posts: 15
Hi

here the "int" will be printed because the ascii value will be passed. U can print the value i to know it ..


Regards,<br /> <br />GILLI
natarajan raman
Greenhorn

Joined: Apr 10, 2004
Posts: 26
Hi Peter,

This prints "int" because the when t.c(ch) is called it looks for the function with argument as Character.

char is essentially the only unsigned integral type. So when it calls invokes the first function with integer argument.

Hope this helps.


nata.r<br />**********************************<br />To win is not always success<br />And to lose is not always failure.<br />**********************************
VINCE CARTER
Greenhorn

Joined: Sep 26, 2004
Posts: 13
Thanks !!!
 
 
subject: scjp question required