Final.fa10

# Final.fa10 - Student ID Name cs8f Signature CSE 8A Final...

This preview shows pages 1–4. Sign up to view the full content.

Student ID ____________________ Name ________________________ cs8f ____ Signature _____________________ CSE 8A Final Fall 2010 Page 1 ___________ (10 points) Page 2 ___________ (9 points) Page 3 ___________ (7 points) Page 4 ___________ (12 points) Page 5 ___________ (12 points) Page 6 ___________ (11 points) Page 7 ___________ (14 points) Page 8 ___________ (14 points) Page 9 ___________ (10 points) Total ___________ (99 points = 94 base points + 5 points EC [5%]) This exam is to be taken by yourself with closed books, closed notes, no electronic devices. You are allowed both sides of an 8.5"x11" sheet of paper handwritten by you.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
1 (Partial) Operator Precedence Table Operators Associativity ! ++ -- (pre & post inc/dec) right to left * / % left to right + - left to right < <= > >= left to right == != left to right && left to right || left to right = right to left What gets printed? public class F2 { public static void main( String[] args ) { System.out.println( -1 + 2 - 3 * 10 % 4 ); _________ System.out.println( 2 * 7 - 11 / 9 + 10 ); _________ } } What gets printed? public class F3 { public static void main( String[] args ) { int fire = 10, air = 2; fire = fire * (air + 5); System.out.println( "fire = " + fire ); ________________________ fire = 5 – air--; System.out.println( "fire = " + fire + "; air = " + air );________________________ fire = 5; air = ++fire + 4; System.out.println( "fire = " + fire + "; air = " + air );________________________ } } What is printed by the following code? int foo = 42; int bar = 42; boolean foobar = ( foo == bar ); System.out.println( foobar ); ____________ foo = 37; System.out.println( foobar ); ____________ System.out.println( foo == bar ); ____________
Fill in the blank so the code will print out 2 System.out.println( (____________) (5.0 / 2.0) ); What does the statement System.out.println( "The answer is: " + 5 + 7 + 2 ); print? ________________________________ What does the statement System.out.println( "The answer is: " + 5 + (7 + 2) ); print? ________________________________ What does the statement System.out.println( "The answer is: " + (5 + 7) + 2 ); print? ________________________________ What does the statement System.out.println( !(2 > 3) ); print? ________________________________ What does int x = 15 % 3; System.out.println( x ); print? ________________________________ What is the full name of the file that this Java code below must be saved as? ____________________________ public class Cafe { /* Body of the class here. */ } What is stored in the memory location allocated for the variable x for the following: (Circle the correct answer.) String x = "-99"; A) x B) a reference (or address in memory) to where the string "-99" is stored C) the value -99 D) int What is stored in the memory location allocated for the variable x for the following: (Circle the correct answer.) int x = -99;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 08/31/2011 for the course CSE 8a taught by Professor Kube,p during the Fall '08 term at UCSD.

### Page1 / 12

Final.fa10 - Student ID Name cs8f Signature CSE 8A Final...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online