?? mockcert05.txt
字號(hào):
Question 1
===========================================================
Which of the following are valid definitions of an application's main( ) method?
Mutiple: ________________
1) public static void main();
2) public static void main(String args);
3) public static void main(String args[]);
4) public static void main(Graphics g);
5) public static boolean main(String args[]);
Question 2
===========================================================
If MyProg.java were compiled as an application and then run from the command line as:
java MyProg I like tests
what would be the value of args[ 1 ] inside the main( ) method?
Mutiple: ________________
1) MyProg
2) "I"
3) "like"
4) 3
5) 4
Question 3
===========================================================
Which of the following are Java keywords?
Mutiple: ________________
1) array
2) boolean
3) Integer
4) protect
5) super
Question 4
===========================================================
After the declaration:
char[] c = new char[100];
what is the value of c[50]?
Only One: _______
1) 50
2) 49
3) '\u0000'
4) '\u0020'
5) always null until a value is assigned
Question 5
===========================================================
If raf is a RandomAccessFile, what is the result of compiling and executing the following code?
raf.seek( raf.length() );:
Only One: _______
1) The code will not compile.
2) An IOException will be thrown.
3) The file pointer will be positioned immediately before the last character of the file.
4) The file pointer will be positioned immediately after the last character of the file.
Question 6
===========================================================
Which identifiers are valid?
Mutiple: ________________
1) _xpoints
2) r2d2
3) bBb$
4) set-flow
5) thisisCrazy
Question 7
===========================================================
A directory can be created using a method from the class(es):
Mutiple: ________________
1) File
2) DataOutput
3) Directory
4) FileDescriptor
5) FileOutputStream
Question 8
===========================================================
Which of the following statements assigns "Hello Java" to the String variable s?
Mutiple: ________________
1) String s = "Hello Java";
2) String s[] = "Hello Java";
3) new String s = "Hello Java";
4) String s = new String("Hello Java");
Question 9
===========================================================
An integer, x has a binary value (using 1 byte) of 10011100. What is the binary value of z after these statements:
int y = 1 << 7;
int z = x & y;
Only One: _______
1) 1000 0001
2) 1000 0000
3) 0000 0001
4) 1001 1101
5) 1001 1100
Question 10
===========================================================
Which statements are accurate:
Mutiple: ________________
1) >> performs signed shift while >>> performs an unsigned shift.
2) >>> performs a signed shift while >> performs an unsigned shift.
3) << performs a signed shift while <<< performs an insigned shift.
4) <<< performs a signed shift while << performs an unsigned shift.
Question 11
===========================================================
The statement ...
String s = "Hello" + "Java";
yields the same value for s as ...
String s = "Hello";
String s2= "Java";
s.concat( s2 );
Only One: _______
1) True
2) False
Question 12
===========================================================
If you compile and execute an application with the following code in its main() method:
String s = new String( "Computer" );
if( s == "Computer" )
System.out.println( "Equal A" );
if( s.equals( "Computer" ) )
System.out.println( "Equal B" );
Only One: _______
1) It will not compile because the String class does not support the = = operator.
2) It will compile and run, but nothing is printed.
3) "Equal A" is the only thing that is printed.
4) "Equal B" is the only thing that is printed.
5) Both "Equal A" and "Equal B" are printed.
Question 13
===========================================================
Consider the two statements:
1. boolean passingScore = false && grade == 70;
2. boolean passingScore = false & grade == 70;
The expression
grade == 70
is evaluated:
Mutiple: ________________
1) in both 1 and 2
2) in neither 1 nor 2
3) in 1 but not 2
4) in 2 but not 1
5) invalid because false should be FALSE
Question 14
===========================================================
Given the variable declarations below:
byte myByte;
int myInt;
long myLong;
char myChar;
float myFloat;
double myDouble;
Which one of the following assignments would need an explicit cast?
Mutiple: ________________
1) myInt = myByte;
2) myInt = myLong;
3) myByte = 3;
4) myInt = myChar;
5) myFloat = myDouble;
Question 15
===========================================================
Consider this class example:
class MyPoint
{ void myMethod()
{ int x, y;
x = 5; y = 3;
System.out.print( " ( " + x + ", " + y + " ) " );
switchCoords( x, y );
System.out.print( " ( " + x + ", " + y + " ) " );
}
void switchCoords( int x, int y )
{ int temp;
temp = x;
x = y;
y = temp;
System.out.print( " ( " + x + ", " + y + " ) " );
}
}
What is printed to standard output if myMethod() is executed?
Only One: _______
1) (5, 3) (5, 3) (5, 3)
2) (5, 3) (3, 5) (3, 5)
3) (5, 3) (3, 5) (5, 3)
Question 16
===========================================================
.. To declare an array of 31 floating point numbers representing snowfall for each day of March in Gnome, Alaska, which declarations would be valid?
Mutiple: ________________
1) double snow[] = new double[31];
2) double snow[31] = new array[31];
3) double snow[31] = new array;
4) double[] snow = new double[31];
Question 17
===========================================================
If arr[] contains only positive integer values, what does this function do?
public int guessWhat( int arr[] )
{ int x= 0;
for( int i = 0; i < arr.length; i++ )
x = x < arr[i] ? arr[i] : x;
return x;
}
Mutiple: ________________
1) Returns the index of the highest element in the array
2) Returns true/false if there are any elements that repeat in the array
3) Returns how many even numbers are in the array
4) Returns the highest element in the array
5) Returns the number of question marks in the array
Question 18
===========================================================
Consider the code below:
arr[0] = new int[4];
arr[1] = new int[3];
arr[2] = new int[2];
arr[3] = new int[1];
for( int n = 0; n < 4; n++ )
System.out.println( /* what goes here? */ );
Which statement below, when inserted as the body of the for loop, would print the number of values in each row?
Only One: _______
1) arr[n].length();
2) arr.size;
3) arr.size -1;
4) arr[n][size];
5) arr[n].length;
Question 19
===========================================================
If size = 4, triArray looks like:
int[][] makeArray( int size)
{ int[][] triArray = new int[size] [];
int val=1;
for( int i = 0; i < triArray.length; i++ )
{ triArray[i] = new int[i+1];
for( int j=0; j < triArray[i].length; j++ )
{ triArray[i][j] = val++;
}
}
return triArray;
}
Only One: _______
1) 1 2 3 4
5 6 7
8 9
10
2) 1 4 9 16
3) 1 2 3 4
4) 1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
5) 1
2 3
4 5 6
7 8 9 10
Question 20
===========================================================
Which of the following are legal declarations of a two-dimensional array of integers?
Mutiple: ________________
1) int[5][5]a = new int[][];
2) int a = new int[5,5];
3) int[]a[] = new int[5][5];
4) int[][]a = new[5]int[5];
Question 21
===========================================================
Which of the following are correct methods for initializing the array "dayhigh" with 7 values?
Mutiple: ________________
1) int dayhigh = { 24,23,24,25,25,23,21 };
2) int dayhigh[] = { 24,23,24,25,25,23,21 };
3) int[] dayhigh = { 24,23,24,25,25,23,21 };
4) int dayhigh[] = new int[24,23,24,25,25,23, 21];
Question 22
===========================================================
A "mode" argument such as "r" or "rw" is required in the constructor for the class(es):
Mutiple: ________________
1) DataInputStream
2) InputStream
3) RandomAccessFile
4) File
5) None of the above
Question 23
===========================================================
Choose all valid forms of the argument list for the FileOutputStream constructor shown below:
Mutiple: ________________
1) FileOutputStream(FileDescriptor fd)
2) FileOutputStream(String n, boolean a)
3) FileOutputStream(boolean a)
4) FileOutputStream()
5) FileOutputStream(File f)
Question 24
===========================================================
Consider the code below:
public static void main( String args[] )
{ int a = 5;
System.out.println( cube( a ) );
}
int cube( int theNum )
{
return theNum * theNum * theNum;
}
What will happen when you attempt to compile and run this code?
Mutiple: ________________
1) It will not compile because cube is already defined in the java.lang.Math class.
2) It will not compile because cube is not static.
3) It will compile, but throw an arithmetic exception.
4) It will run perfectly and print "125" to standard output.
Question 25
===========================================================
Given the variables defined below:
int one = 1;
int two = 2;
char initial = '2';
boolean flag = true;
Which of the following are valid?
Mutiple: ________________
1) if( one ){}
2) if( one = two ){}
3) if( one == two ){}
4) if( flag ){}
5) switch( one ){}
Question 26
===========================================================
If val = 1 in the code below:
switch( val )
{ case 1: System.out.print( "P" );
case 2:
case 3: System.out.print( "Q" );
break;
case 4: System.out.print( "R" );
default: System.out.print( "S" );
}
Which values would be printed?
Mutiple: ________________
1) P
2) Q
3) R
4) S
Question 27
===========================================================
Assume that val has been defined as an int for the code below:
if( val > 4 )
{ System.out.println( "Test A" );
}
else if( val > 9 )
{ System.out.println( "Test B" );
}
else System.out.println( "Test C" );
Which values of val will result in "Test C" being printed:
Mutiple: ________________
1) val < 0
2) val between 0 and 4
3) val between 4 and 9
4) val > 9
5) val = 0
Question 28
===========================================================
Which of the following describe the sequence of method calls that result in a component being redrawn?
Mutiple: ________________
1) invoke paint() directly
2) invoke update which calls paint()
3) invoke repaint() which invokes update(), which in turn invokes paint()
4) invoke repaint() which invokes paint directly
Question 29
===========================================================
For the code:
m = 0;
while( m++ < 2 )
System.out.println( m );
Which of the following are printed to standard output?
Mutiple: ________________
1) 0
2) 1
3) 2
4) 3
5) Nothing and an exception is thrown
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -