|
|
Welcome to the Java Forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
- have access to post topics
- communicate privately with other members (PM)
- not see advertisements between posts
- have the possibility to earn one of our surprises if you are an active member
- access many other special features that will be introduced later.
Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact us.
|
|

05-08-2008, 01:36 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
|
|
Yes pal. Ternary operator become false there.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on July 13, 2008)
|
|

05-08-2008, 01:37 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
|
|
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.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on July 13, 2008)
|
|

05-08-2008, 01:38 PM
|
 |
Senior Member
|
|
Join Date: Mar 2008
Location: Delhi, India
Posts: 160
|
|
sanjeev please post the exact print
like Eranga did
You want the answer ?? 
__________________
Newton said Gravitaion, Rakesh says Earth Sucks
|
|

05-08-2008, 01:40 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
|
|
I'm worried on my last post Rakesh. What you mean the logic of 2.3, any special reason.
May be your answer give the solution.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on July 13, 2008)
|
|

05-08-2008, 01:42 PM
|
 |
Senior Member
|
|
Join Date: Apr 2008
Location: Delhi(India)
Posts: 249
|
|
|
__________________
sanjeev,संजीव
|
|

05-08-2008, 01:43 PM
|
 |
Senior Member
|
|
Join Date: Mar 2008
Location: Delhi, India
Posts: 160
|
|
answer is
Reason being
a>5 evaluates to false so the answer should be
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
and the answer is
__________________
Newton said Gravitaion, Rakesh says Earth Sucks
|
|

05-08-2008, 01:43 PM
|
 |
Senior Member
|
|
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
|
|
|
it should be 2.... i think....
5 never can be called greater than 5......
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

05-08-2008, 01:44 PM
|
 |
Senior Member
|
|
Join Date: Apr 2008
Location: Delhi(India)
Posts: 249
|
|
Originally Posted by Eranga
I'm worried on my last post Rakesh. What you mean the logic of 2.3, any special reason.
May be your answer give the solution.
Actually he is asking that, How you got this ans, What is your logic to calculate the 2.3.
__________________
sanjeev,संजीव
|
|

05-08-2008, 01:47 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
|
|
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 
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on July 13, 2008)
|
|

05-08-2008, 01:47 PM
|
 |
Senior Member
|
|
Join Date: Mar 2008
Location: Delhi, India
Posts: 160
|
|
|
Banana is still with me
answered in #66
Next question Please
__________________
Newton said Gravitaion, Rakesh says Earth Sucks
|
|

05-08-2008, 01:51 PM
|
 |
Senior Member
|
|
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
|
|
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?
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

05-08-2008, 01:52 PM
|
 |
Senior Member
|
|
Join Date: Mar 2008
Location: Delhi, India
Posts: 160
|
|
parse exception 
__________________
Newton said Gravitaion, Rakesh says Earth Sucks
|
|

05-08-2008, 01:54 PM
|
 |
Senior Member
|
|
Join Date: Apr 2008
Location: Delhi(India)
Posts: 249
|
|
|
Number Format Exception...
__________________
sanjeev,संजीव
|
|

05-08-2008, 01:58 PM
|
 |
Senior Member
|
|
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
|
|
|
Yah... NumberFormatException.....
It can never be treat as a pure Floating Decimal values.
...11.5 * 2...
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

05-08-2008, 02:03 PM
|
 |
Senior Member
|
|
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
|
|
Without attempting to compile the code below,
What should be the output?
public class test {
public static void main(String quiz[]) {
System.out.print("H" + "a");
System.out.print('H' + 'a');
}
}
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

05-08-2008, 02:05 PM
|
 |
Senior Member
|
|
Join Date: Apr 2008
Location: Delhi(India)
Posts: 249
|
|
Originally Posted by sukatoa
Without attempting to compile the code below,
What should be the output?
public class test {
public static void main(String quiz[]) {
System.out.print("H" + "a");
System.out.print('H' + 'a');
}
}
Will not compile
__________________
sanjeev,संजीव
|
|

05-08-2008, 02:06 PM
|
 |
Senior Member
|
|
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
|
|
|
Actually it compiles.... it has an output. guess what?
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

05-08-2008, 02:17 PM
|
 |
Senior Member
|
|
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
|
|
|
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,
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

05-08-2008, 02:21 PM
|
 |
Senior Member
|
|
Join Date: Mar 2008
Location: Delhi, India
Posts: 160
|
|
o man! i could have answered it
y i got the mail notification after half an hour 
__________________
Newton said Gravitaion, Rakesh says Earth Sucks
|
|

05-08-2008, 02:29 PM
|
 |
Senior Member
|
|
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
|
|
|
maybe because you have subscribed a specific thread.
next quiz please... i hope i can catch one....
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|
|