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 or false
Question 4
Java is an object-oriented language.
True
False
QUESTION 5
You have successfully compiled the file Hi.java, how do you run the corresponding program from the command line?
java Hi.java | ||
java Hi.class | ||
java Hi | ||
Hi | ||
Hi.class |
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 _________________ .
1 | ||
1.5 | ||
3 | ||
2 | ||
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 _________________
Create | ||
= | ||
new | ||
Object | ||
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? _________________ .
javax.swing | ||
java.swing | ||
java.awt | ||
javax.awt | ||
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 ______ .
0 | ||
1 | ||
NULL | ||
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?
88 and 89 | ||
0 and 90 | ||
89, 90, and 91 | ||
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 _________________ .
grades | ||
grades.size() | ||
grades.size | ||
grades.length() | ||
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? _________________ .
j < length | ||
j < grades.length | ||
j <= grades.length | ||
j < grades[i].length | ||
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?
Reviews
There are no reviews yet.