exit midterm exam

NAME

 
CSE 214: Mid Term Exam
 
Tu, Nov 4, 3:30—4:48
Open Notes, Open Books
The exam consists of seven problems
Answers not appearing in designated spaces WILL NOT be graded

Problem #1 (10 points)
Fill the missing numbers in the following table




DecimalBinaryOctalHexadecimal




17




10101




11




A3




Problem #2 (10 points)
Show the output of the following println instruction.

System.out.println(  
   "\u0047\u006F\u006F\u0064\u0020\114\165\143\153"  
);

ASCII octal codes:










01234567









4 sp ! " # $ % &









5()*+,-./









601234567









7 8 9 : ; < = > ?









10@ABCDEFG









11 H I J K L M N O


















01234567









12 P Q R S T U V W









13XYZ[\]^_









14abcdefg









15hijklmno









16pqrstuvw









17xyz{|}~ 









ASCII hexadecimal codes:


















0123456789ABCDEF

















2 sp ! " # $ % & ( ) * + , - . /

















30123456789:;<=>?

















4@ABCDEFGHIJKLMNO

















5 P Q R S T U V W X Y Z [ \ ] ^ _

















6abcdefghijklmno

















7pqrstuvwxyz{|}~ 

















Problem #3 (10 points)
Show the output of the following code fragment.
for(int c = 0; c < 127; c++) 
{ 
   switch( c ){ 
     case    53: System.out.println( ’5’ ); continue
     case    41: System.out.println( ’!’ ); continue
     case    65: System.out.println( ’A’ ); break
        defaultcontinue
   } 
   break
}
Problem #4 (10 points)
the output of the following code fragment.
int [] x = new int[5]; 
x[0] = 0; 
x[1] = 1; 
x[2] = x[0] + x[1]; 
x[3] = x[0] + x[1] - x[2]; 
x[4] = x[0] + x[1] - x[2] + x[3]; 
forint i = 0; i<5; i++ ) 
{ 
   System.out.print( x[i] + ” ”); 
} 
System.out.println();
Problem #5 (10 points)
Show the output of the following code fragment.
int [][] a = new int [3][2]; 
for(int i=0; i<3; i=i+1 ){ 
   for(int j=0; j<2; j=j+1 ){ 
      a[i][j] = i * j; 
}  } 
for(int i=0; i<3; i=i+1 ){ 
   for(int j=0; j<2; j=j+1 ){ 
      System.out.print( a[i][j] ); 
   } 
   System.out.println (); 
}

Problem #6 (10 points)
Consider the following Exam class.




Field Summary



static intone holds the digit 1



int two holds the digit 2



Constructor Summary



Exam()



Method Summary



static intgetThree()produces the digit 3



int getFour() produces the digit 4



The incomplete program

class Test{ 
   public static void main(String [] args){ 
             = new        ; 
      System.out.println(         one ); 
      System.out.println(         two ); 
      System.out.println(         getThree() ); 
      System.out.println(         getFour() ); 
   } 
}

produces the following output.

1  
2  
3  
4

Add the missing code fragments to the given program. (It is not allowed to remove code from the program.)

Problem #7 (10 points)
Consider the following program.
class Test{ 
   public static void main(String [] args){ 
      Hidden obj  = new Hidden(); 
      Hidden objMax  = new Hidden( Hidden.max ); 
      Hidden objMin  = new Hidden( Hidden.min ); 
      double min = objMin.getValue(); 
      double max = objMax.getValue(); 
      double diff = max-min; 
      obj.setValue( diff ); 
   } 
}

The program uses a class named Hidden. Show the details of the fields, constructors, and methods of the Hidden class that are used in the program.



Field Summary


   


   


Constructor Summary


 


 


Method Summary