File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Mock Exam Errata and the fly likes round up exam #25 urgent Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Mock Exam Errata
Reply Bookmark "round up exam #25 urgent" Watch "round up exam #25 urgent" New topic
Author

round up exam #25 urgent

ravi ckumar
Greenhorn

Joined: Dec 08, 2000
Posts: 18
during the arithematic when the operands are of different types the resulting type is always the widest of the 2 types for which the answer was given as false
but i feel the answer is true cause if u add an int + float the result is always float.
the answer given was also not clear, but why was it given as false i feel the answer is true can anybody pls explain
Kathy Rogers
Ranch Hand

Joined: Aug 04, 2000
Posts: 103
What about
short i = 3;
byte j = 4;
What's the result of
k = i+j
or
k = i*j
k can't be a short because i and j are automatically promoted to ints during the arithmatic operation - but an int is wider than the widest type of either variable (short).
So sometimes when the operands are of different types, they're automatically promoted to something other than the widest type. That's why it's false.
Hope this helps,
Kathy
 
IntelliJ Java IDE
 
subject: round up exam #25 urgent
 
Threads others viewed
javaranch game
operators
Ques. from JTips Mock 1
Question related to Garbage Collector
unsigned right shift
IntelliJ Java IDE