Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes boone exam q -- assignments, help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "boone exam q -- assignments, help" Watch "boone exam q -- assignments, help" New topic
Author

boone exam q -- assignments, help

sarim raza
Ranch Hand

Joined: Nov 02, 2000
Posts: 232
Question 29: What is the result of executing the following code:
class Test {
public static void main(String[] args) {
Test t = new Test();
t.test(1.0, 2L, 3);
}
void test(double a, double b, short c) {
System.out.println("1");
}
void test(float a, byte b, byte c) {
System.out.println("2");
}
void test(double a, double b, double c) {
System.out.println("3");
}
void test(int a, long b, int c) {
System.out.println("4");
}
void test(long a, long b, long c) {
System.out.println("5");
}
}
Select the one right answer.
a.1
b.2
c.3
d.4
e.5

//ANSWRE IS C BUT WHY ISNT A CORRECT, THE 3 THAT IS PASSED TO THE SHORT, ISNT THAT A TOTALLY PERFECT ASSIGNMENT OF VALUE TO A SHORT
SIMILAR TO short s = 3; ???
Michael Burke
Ranch Hand

Joined: Jul 29, 2000
Posts: 103
Yes, but the second parameter passed is a long which can't automatically be converted to a double.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: boone exam q -- assignments, help
 
Similar Threads
Question from New Boone
Why this Output?
Barry Boone #29
conversion and casting
Primitive Data Types