COMP 328 All Assignments COMP 328 All Assignments | Page 4
* 7;
+ c * a;
}
}
Mark the following statements as TRUE or FALSE.
q is a reference variable which refers to the empty string. __TRUE___ b and c are local
variables. ___TRUE____ a, b, and c are primitive data types. ___FALSE____ MyClass is a Java
application. ___FALSE____
8: Which statement below could be used to randomly select a state from an array which
contains exactly 50 strings which are the names of the states?
1 + ( int ) ( Math.random( ) * 49 ); ( int ) ( Math.random( ) * 51 ); ( int ) ( Math.random( ) * 50 );
1 + ( int ) ( Math.random( ) * 50 );
9: To draw a single line from (0, 15) to (20, 25), call the method _________ of the Graphics class
in the paintComponent method.
a.drawLine( 0, 15, 20, 25 );
b.drawString( "single line", 0, 15 );
c.drawLine( 0, 15, 20, 10 );
d.drawLine( 15, 0, 25, 20 );
10: In the Java graphics system, coordinate units are measured in ________.
a.dots
b.pixels
c.points
d.inches
11: Which is a correct way to invoke the static method sqrt of the Math class?
a.sqrt( 900 );.
b.math.sqrt( 900 );.