?? mockcert05.txt
字號:
Question 30
===========================================================
Consider the code fragment below:
outer: for( int i = 1; i <3; i++ )
{ inner: for( j = 1; j < 3; j++ )
{ if( j==2 )
continue outer;
System.out.println( "i = " +i ", j = " + j );
}
}
Which of the following would be printed to standard output?
Mutiple: ________________
1) i = 1, j = 1
2) i = 1, j = 2
3) i = 1, j = 3
4) i = 2, j = 1
5) i = 2, j = 2
Question 31
===========================================================
Consider the code below:
void myMethod()
{ try
{
fragile();
}
catch( NullPointerException npex )
{
System.out.println( "NullPointerException thrown " );
}
catch( Exception ex )
{
System.out.println( "Exception thrown " );
}
finally
{
System.out.println( "Done with exceptions " );
}
System.out.println( "myMethod is done" );
}
What is printed to standard output if fragile() throws an IllegalArgumentException?
Mutiple: ________________
1) "NullPointerException thrown"
2) "Exception thrown"
3) "Done with exceptions"
4) "myMethod is done"
5) Nothing is printed
Question 32
===========================================================
Consider the following code sample:
class Tree{}
class Pine extends Tree{}
class Oak extends Tree{}
public class Forest
{ public static void main( String[] args )
{ Tree tree = new Pine();
if( tree instanceof Pine )
System.out.println( "Pine" );
if( tree instanceof Tree )
System.out.println( "Tree" );
if( tree instanceof Oak )
System.out.println( "Oak" );
else System.out.println( "Oops" );
}
}
Select all choices that will be printed:
Mutiple: ________________
1) Pine
2) Tree
3) Forest
4) Oops
5) (nothing printed)
Question 33
===========================================================
Consider the classes defined below:
import java.io.*;
class Super
{
int methodOne( int a, long b ) throws IOException
{ // code that performs some calculations
}
float methodTwo( char a, int b )
{ // code that performs other calculations
}
}
public class Sub extends Super
{
}
Which of the following are legal method declarations to add to the class Sub? Assume that each method is the only one being added.
Mutiple: ________________
1) public static void main( String args[] ){}
2) float methodTwo(){}
3) long methodOne( int c, long d ){}
4) int methodOne( int c, long d ) throws ArithmeticException{}
5) int methodOne( int c, long d ) throws FileNotFoundException{}
Question 34
===========================================================
Assume that Sub1 and Sub2 are both subclasses of class Super.
Given the declarations:
Super super = new Super();
Sub1 sub1 = new Sub1();
Sub2 sub2 = new Sub2();
Which statement best describes the result of attempting to compile and execute the following statement:
super = sub1;
Only One: _______
1) Compiles and definitely legal at runtime
2) Does not compile
3) Compiles and may be illegal at runtime
Question 35
===========================================================
For the following code:
class Super
{ int index = 5;
public void printVal()
{ System.out.println( "Super" );
}
}
class Sub extends Super
{ int index = 2;
public void printVal()
{ System.out.println( "Sub" );
}
}
public class Runner
{ public static void main( String argv[] )
{ Super sup = new Sub();
System.out.print( sup.index + "," );
sup.printVal();
}
}
What will be printed to standard output?
Only One: _______
1) The code will not compile
2) The code compiles and "5, Super" is printed to standard output.
3) The code compiles and "5, Sub" is printed to standard output.
4) The code compiles and "2, Super" is printed to standard output.
5) The code compiles and "2, Sub" is printed to standard output.
Question 36
===========================================================
How many objects are eligible for garbage collection once execution has reached the line labeled Line A?
String name;
String newName = "Nick";
newName = "Jason";
name = "Frieda";
String newestName = name;
name = null;
//Line A
Only One: _______
1) 0
2) 1
3) 2
4) 3
5) 4
Question 37
===========================================================
Which of the following statements about Java's garbage collection are true?
Mutiple: ________________
1) The garbage collector can be invoked explicitly using a Runtime object.
2) The finalize method is always called before an object is garbage collected.
3) Any class that includes a finalize method should invoke its superclass' finalize method.
4) Garbage collection behavior is very predictable.
Question 38
===========================================================
Which of the following statements about event handling in JDK 1.1 and later are true?
Mutiple: ________________
1) A class can implement multiple listener interfaces
2) If a class implements a listener interface, it only has to overload the methods it uses
3) All of the MouseMotionAdapter class methods have a void return type.
Question 39
===========================================================
Which methods are required to implement the interface Runnable.
Mutiple: ________________
1) wait()
2) run()
3) stop()
4) update()
5) resume()
Question 40
===========================================================
A component that should resize vertically but not horizontally should be placed in a:
Mutiple: ________________
1) BorderLayout in the North or South location
2) FlowLayout as the first component
3) BorderLayout in the East or West location
4) BorderLayout in the Center location
5) GridLayout
Question 41
===========================================================
For what reasons might a thread stop execution?
Mutiple: ________________
1) A thread with higher priority began execution.
2) The thread's wait() method was invoked.
3) The thread invoked its yield() method.
4) The thread's pause() method was invoked.
5) The thread's sleep() method was invoked.
Question 42
===========================================================
Which method below can change a String object, s ?
Mutiple: ________________
1) equals( s )
2) substring( s )
3) concat( s )
4) toUpperCase( s )
5) none of the above will change s
Question 43
===========================================================
If s1 is declared as:
String s1 = "phenobarbital";
What will be the value of s2 after the following line of code:
String s2 = s1.substring( 3, 5 );
Only One: _______
1) null
2) "eno"
3) "enoba"
4) "no"
Question 44
===========================================================
What method(s) from the java.lang.Math class might method() be if the statement
method( -4.4 ) == -4;
is true.
Mutiple: ________________
1) round()
2) min()
3) trunc()
4) abs()
5) ceil()
Question 45
===========================================================
Which methods does java.lang.Math include for trigonometric computations?
Mutiple: ________________
1) sin()
2) cos()
3) tan()
4) aSin()
5) aCos()
Question 46
===========================================================
This piece of code:
TextArea ta = new TextArea( 10, 3 );
Produces (select all correct statements):
Mutiple: ________________
1) a TextArea with 10 rows and up to 3 columns
2) a TextArea with a variable number of columns not less than 10 and 3 rows
3) a TextArea that may not contain more than 30 characters
4) a TextArea that can be edited
Question 47
===========================================================
In the list below, which subclass(es) of Component cannot be directly instantiated:
Mutiple: ________________
1) Panel
2) Dialog
3) Container
4) Frame
Question 48
===========================================================
Of the five Component methods listed below, only one is also a method of the class MenuItem. Which one?
Only One: _______
1) setVisible( boolean b )
2) setEnabled( boolean b )
3) getSize()
4) setForeground( Color c )
5) setBackground( Color c )
Question 49
===========================================================
If a font with variable width is used to construct the string text for a column, the initial size of the column is:
Only One: _______
1) determined by the number of characters in the string, multiplied by the width of a character in this font
2) determined by the number of characters in the string, multiplied by the average width of a character in this font
3) exclusively determined by the number of characters in the string
4) undetermined
Question 50
===========================================================
Which of the following methods from the java.awt.Graphics class would be used to draw the outline of a rectangle with a single method call?
Mutiple: ________________
1) fillRect()
2) drawRect()
3) fillPolygon()
4) drawPolygon()
5) drawLine()
Question 51
===========================================================
The Container methods add( Component comp ) and add( String name, Component comp ) will throw an IllegalArgumentException if comp is a:
Mutiple: ________________
1) button
2) list
3) window
4) textarea
5) container that contains this container
Question 52
===========================================================
Of the following AWT classes, which one(s) are responsible for implementing the components layout?
Mutiple: ________________
1) LayoutManager
2) GridBagLayout
3) ActionListener
4) WindowAdapter
5) FlowLayout
Question 53
===========================================================
Which of the following are valid ways to define an octal literal of value 17 (octal).
Mutiple: ________________
1) private final int theNumber = 0x17;
2) private final int theNumber = 017;
3) public int theNumber = 017;
4) public int theNumber = (octal)17;
5) public int THE_NUMBER = 017;
Question 54
===========================================================
Consider the following piece of code and select all statements which yield a boolean value of true as a result.
Double d1=new Double(10.0);
Double d2=new Double(10.0);
int x=10;
float f=10.0
Mutiple: ________________
1) d1 == d2;
2) d1 == x;
3) f == x;
4) d1.equals(d2);
5) None of the above
Question 55
===========================================================
Given the following definition:
String s = null;
Which code fragment will cause an exception of type NullPointerException to be thrown.
Mutiple: ________________
1) if ((s != null) & (s.length()>0))
2) if ((s != null) && (s.length()>0))
3) if ((s != null) | (s.length()>0))
4) if ((s != null) || (s.length()>0))
5) None of the above.
Question 56
===========================================================
Which of the following are valid declarations for a 2x2 array of integers.
Mutiple: ________________
1) int a[][] = new int[10,10];
2) int a[][] = new int [10][10];
3) int a[10,10] = new int [10][10];
4) int [][]a = new int [10][10];
5) int []a[] = new int [10][10];
Question 57
===========================================================
Which values of variable x will show "Message 2".
switch(x)
{
case 1 :
System.out.println("Message 1");
case 2 :
case 3 :
System.out.println("Message 2");
default :
System.out.println("End");
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -