Some Simple Written Questions

No, you can't have a sip of my Java.

Some Simple Written Questions

Postby The3point14 » Thu Apr 05, 2007 5:08 pm

This is found on the cis 0506-03 test:

17) Which of the following would replace <#1> so the output is true?

int a = Integer.MAX_VALUE;
a++;
System.out.println(a == <#1>);

the answer is both, Integer.MIN_VALUE, and Math.abs(a);

I understand the MIN_VALUE half of the answer, but how does the absolute value work?
-- 2008 4A State Calculator Champion --
User avatar
The3point14
Determined Spammer
 
Posts: 180
Joined: Sat Oct 21, 2006 1:41 pm
Location: Austin

Postby Quelloquialism » Thu Apr 05, 2007 5:11 pm

Integer.MAX_VALUE + 1 = Integer.MIN_VALUE due to integer overflow.

Math.abs(Integer.MIN_VALUE) = -Integer.MIN_VALUE = Integer.MAX_VALUE + 1 = Integer.MIN_VALUE all over again. Absolute value overflows the integer on MIN_VALUE.
Quelloquialism
Celebrated Spammer
 
Posts: 534
Joined: Tue Oct 24, 2006 8:02 pm
Location: TopCoder Chat Room 1

Postby The3point14 » Thu Apr 05, 2007 5:27 pm

Ah I understand, thanks. Hopefully in the next week I will have a few more questions that I don't know how to do for you to solve Nathan, as well as anyone else that can help :).
-- 2008 4A State Calculator Champion --
User avatar
The3point14
Determined Spammer
 
Posts: 180
Joined: Sat Oct 21, 2006 1:41 pm
Location: Austin

Postby MistaPotta » Thu Apr 05, 2007 7:55 pm

Gotta love the odometer effect!
User avatar
MistaPotta
<sigh> No, I haven't uploaded that yet...
 
Posts: 567
Joined: Thu Oct 19, 2006 8:33 pm
Location: Deep in the heart of Helotes!

Postby The3point14 » Fri Apr 06, 2007 3:56 pm

Also I am missing page 3 in the 2006 UIL District 1 test.

Thanks ^_^
-- 2008 4A State Calculator Champion --
User avatar
The3point14
Determined Spammer
 
Posts: 180
Joined: Sat Oct 21, 2006 1:41 pm
Location: Austin


Return to UIL Computer Science

Who is online

Users browsing this forum: No registered users and 1 guest

cron