Forums Register Login

boone exam q -- assignments, help

+Pie Number of slices to send: Send
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; ???
+Pie Number of slices to send: Send
Yes, but the second parameter passed is a long which can't automatically be converted to a double.
I RELEASE YOU! (for now .... ) Feel free to peruse this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 649 times.
Similar Threads
Why this Output?
conversion and casting
Primitive Data Types
Barry Boone #29
Question from New Boone
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:50:44.