1. Originally Posted by rjuyal
BTW, what's the logic behing 2.3

i will post the answer with reason after this :)
I didn't get you on this pal.

2. Java Code:
`Value will be 2`
sanjeev please post the exact print

like Eranga did

Java Code:
`Value is - 2.3`

You want the answer ?? :rolleyes:

3. I'm worried on my last post Rakesh. What you mean the logic of 2.3, any special reason.

4. Java Code:
`Value is - 2`

Java Code:
`Value is: - 2.0`
Reason being

a>5 evaluates to false so the answer should be

Java Code:
`Value is: - 2`
but,

2.3 ( double) and 2(int) are of different types. So the type chosen by Ternary will be by rule of promotion, hence 2 will be converted to 2.0

Java Code:
`Value is: - 2.0`

6. it should be 2.... i think....

5 never can be called greater than 5......

7. Originally Posted by Eranga
I'm worried on my last post Rakesh. What you mean the logic of 2.3, any special reason.

Actually he is asking that, How you got this ans, What is your logic to calculate the 2.3.

8. Ah, a nice point. ternary operator evaluates integer values. :)

Anyway, I have to go now my friends. Keep going, I'll back to here tomorrow. Nice work pal. Thanks for all of you. Keep going this, rather starting a new one. Doesn't matter how it long. I'll manage i'll manage it for all of you.

Good luck,
Eranga:):)

9. ## Banana is still with me

10. Java Code:
```public class test{
public static void main(String quiz[]){
String t1 = "23";
String t2 = "11.5 * 2";
if(Double.valueOf(t1)==Double.valueOf(t2))
System.out.print("true");
else
System.out.print("absolutely impossible");
}
}```
What can you guess about the code above?

11. parse exception :confused:

12. Number Format Exception...

13. Yah... NumberFormatException.....

It can never be treat as a pure Floating Decimal values.
...11.5 * 2...

14. Without attempting to compile the code below,

What should be the output?

Java Code:
```public class test {

public static void main(String quiz[]) {

System.out.print("H" + "a");

System.out.print('H' + 'a');

}

}```

15. Originally Posted by sukatoa
Without attempting to compile the code below,

What should be the output?

Java Code:
```public class test {

public static void main(String quiz[]) {

System.out.print("H" + "a");

System.out.print('H' + 'a');

}

}```

Will not compile

16. Actually it compiles.... it has an output. guess what?

17. at first attempt of printing "Ha", allowable... obviously,

The problem is on the second attempt....
H and a are now char literals... There decimal value will be printed.. instead of concatenating like the previous one, it now adds their decimal representation that leads to 169

eg. Ha169.

ref, ascii chart.

Just sharing,

18. o man! i could have answered it :(

y i got the mail notification after half an hour :eek:

19. maybe because you have subscribed a specific thread.

next quiz please... i hope i can catch one....

Page 4 of 55 First ... 234561454 ... Last

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•