QUESTION 1 Give two examples of Operating Systems.
QUESTION 2 Unicode is a world standard to represent _________________
QUESTION 3 Java is a high-level language
True
False
QUESTION 4 Java is an object-oriented language.
True
False
QUESTION 5You have successfully compiled the file Hi.java, how do you run the corresponding program from the command line?
a. java Hi.java
b. java Hi.class
c. java Hi
d. Hi
e. Hi.class
QUESTION 6 A double is more precise than a float.
True
False
QUESTION 7 char values are surrounded by _____ quotes
QUESTION 8 String literals are surrounded by _____ quotes
QUESTION 9 The result of 3.0 / 2 is _________________ .
a. 1
b. 1.5
c. 3
d. 2
e. 0
QUESTION 10 If you have written the following source code:
public class SpringBreak?{? // lots of code here?}
then your source code should be saved in a file named _______________
QUESTION 11 What keyword do we use when instantiating an object _________________
a. Create
b. =
c. new
d. Object
e. is
QUESTION 12 The operations for a class are called _____
QUESTION 13 The special method that we call when instantiating an object is called a _____
QUESTION 14 Write Java statements to instantiate a random number generator object and generate a random integer between 100 and 250 (inclusive).
QUESTION 15 Complete this code in main to perform the requested operations for a date entered by the user in this format: month dd, yyyy
public static void main( String [] args )
{
Scanner scan = new Scanner( System.in );
System.out.print( "Enter a date > " );
String date = scan.nextLine( );
// a. output the first letter in the month
// b. output the date in all lowercase letters
/* c. output the year portion of the date, that is, the characters in the date that follow the comma. For example, if the date is February 24, 2016, you would output 2016. (Note, your code should work for ANY date in that format.) */
QUESTION 16 Which package is the Graphics class part of? _________________ .
a. javax.swing
b. java.swing
c. java.awt
d. javax.awt
e. java.graphics
QUESTION 17 The name of the method used to set the current color is _________________
QUESTION 18 Complete the code, drawing a line between points (100, 200) and (34, 67)
public void paint( Graphics g )
{
// your code goes here
}
QUESTION 19 Complete the code, drawing a solid circle (with the current color, whatever it is) so that its diameter is 200, and the coordinates of its center are ( 250, 150 )
public void paint( Graphics g )
{
// your code goes here
}
QUESTION 20 The access modifier of constructors should be _________________
QUESTION 21 When you use a while loop to compute the product of several values, you should initialize the variables holding the product to ______ .
a. 0
b. 1
c. NULL
d. There is no need to initialize it
QUESTION 22 When a loop condition is grade >= 90, what values would you use to test your loop?
a. 88 and 89
b. 0 and 90
c. 89, 90, and 91
d. 90, 91, and 92
QUESTION 23 What is the output of this code sequence?
for ( int i = 5; i >= 0; i-- )
System.out.print( i + " " );
System.out.println( );
QUESTION 24 Write a loop to output the word EXAM 99 times
QUESTION 25 To access the number of elements in an array named grades, we use _________________ .
a. grades
b. grades.size()
c. grades.size
d. grades.length()
e. grades.length
QUESTION 26 Write the code to compute and output how many times the value 99 is found in an array of integers named numbers.
QUESTION 27 When processing all the elements of row i of a two-dimensional array named grades using a for loop with variable j, what is the condition of the for loop? _________________ .
a. j < length
b. j < grades.length
c. j <= grades.length
d. j < grades[i].length
e. j <= grades[i].length
QUESTION 28 The variable numbers is a 2-dimensional array of type int; output all of its elements that are strictly greater than 10
QUESTION 29 What is the error and why is there an error in the code below?
public class XYZ
{
public static final int A = 9;
public abstract void foo1( );
public int foo2( )
{
return 5;
}
}
QUESTION 30 When we read objects from a file using the readObject method, what happens when the end of the file is reached?
QUESTION 31 What is the output of the following sequence?
Scanner scan = new Scanner( System.in );
int number = 0;
try
{
number = scan.nextInt( ); // User enters 12, hits ENTER
System.out.println( "1: " + number );
number = scan.nextInt( ); // User enters 56, hits ENTER
System.out.println( "2: " + number );
number = scan.nextInt( ); // User enters 99ABC, hits ENTER
System.out.println( "3: " + number );
}
catch( Exception e)
{
String s = scan.nextLine( );
System.out.println( "4: " + number );
}
finally
{
number = scan.nextInt( ); // User enters 100, hits ENTER
System.out.println( "5: " + number );
}
QUESTION 32 In the BorderLayout class, what are NORTH, SOUTH, EAST, WEST, and CENTER?
QUESTION 33
Write a program that displays a text field and two buttons labeled "uppercase" and "lowercase". When the user clicks on the uppercase button, the text changes to uppercase; when the user clicks on the lowercase button, the text changes to lowercase.