SCJP 模拟题200道附答案
Q1 Which of the following statements are valid, given the following variable declarations: boolean a; boolean b; int c; 1) (a | b) 2)(a || a) 3)(a ^ b) | c 4)(a & c) 5)(a && c)
Q2 Which of the following can be applied to constructors: 1) final 2) static
3) synchronized 4) native
5) None of these.
Q3 Which of the following retain their preferred size (width and height) when added (individually) to the North section of a container with a BorderLayout (assume that no other components or containers are present in the North section). 1) TextArea 2) Button 3) TextField 4) Checkbox
5) None. All of these mentioned components will only retain their preferred height.
Q4 Which of the following are legal names for variables. 1) _int 2) %large 3) $fred 4) Integer 5) 2much
Q5 Which of the following are correct ways to create a font. 1) Font f = new Font(\Font.BOLD, 24); 2) Font f = new Font(Font.SERIF, \24); 3) Font f = new Font(\\24);
4) Font f = new Font(Font.SERIF, Font.BOLD, 24);
Q6 Select the correct statements regarding the following piece of code. File f = new File(\
1) On execution, a file called \will be created on the local harddi
sk.
2) The code fails to compile on a UNIX machine, because the directory separator is not correct.
3) A file is NOT created on the harddisk when this code is executed.
4) An exception is thrown at runtime if the file \already exists. 5) The code fails to compile, since this is not a valid constructor for the File class.
Q7 Which of the following statements are correct regarding the RandomAccessFile class?
1) An IOException is thrown if the specified file doesn't exist when created using the \mode.
2) This class has a method which allows a file to be deleted from the harddisk.
3) It is possible to use this class in conjunction with the DataInputStream class.
4) When used with the \mode, the specified file is created on a diskdrive, if it doesn't already exist.
5) There are methods to read and write primatives (eg, readInt(), writeInt(), etc).
Q8 Consider the following piece of code and select the correct statement from the following.
1.String s = new String(\ 2.s.replace('d', 'q');
3.System.out.println(s);
1) The code fails to compile, reporting an error at line 2. Strings are immutable, and therefore a replace() method is meaningless.
2) The code compiles correctly, and displays the text \ 3) The code compiles correctly, and displays the text \
4) The code compiles, but an exception is thrown when line 2 is executed.
5) The code compiles, but an exception is thrown at line 3.
Q9 Which of the following keywords can be applied to the variables or methods of an interface. 1) static 2) private
3) synchronised 4) protected 5) public
Q10 True or False.
Only Frames can contain menu bars or pull-down menus.
1) True 2) False.
Q11 Consider the following piece of code and select the correct statement(s):
1. class A{
2. protected int method(){ 3. } 4. } 5.
6. class B extends A{ 7. int method(){ 8. } 9. }
1) The code fails to compile, because you can't override a method to be more private than its parent.
2) The code fails to compile, because method() is declared as protected, and is therefore not available to any subclass.
3) The code compiles correctly, but throws a NullPointerException at runtime.
4) The code fails to compile. However, it can be made to compile correctly by prefixing line 7 with the access qualifier \
5) The code fails to compile. However, it can be made to compile correctly by prefixing line 7 with the access qualifier \ Q12 True or False.
The Throwable class is the superclass of all exceptions in the Java language.
1) True 2) False
Q13 Consider the following piece of code (assume the Graphics context g is defined correctly):
g.setBackground(Color.red); g.setForeground(Color.white); g.drawLine(10, 10, 50, 10); g.setForeground(Color.blue); g.drawRect(100, 100, 50, 50);
What is displayed when this code is executed.
1) A blue line from (10,10) to (50,10) and a blue rectangle with upper left corner at (100,100).
2) A white line from (10,10) to (50,10) and a blue square with top left corner at (100,100).
3) A white line from (10,10) to (10,50) and a blue square with lower left corner at (100,100).
4) A red line from (10, 10) to (50,10) and a red square with upper left corner at (100,100).
5) Nothing is displayed. You must first issue a repaint() command. Q14 Consider the following piece of code. class Test{
public static void main(String [] args){ System.out.println(args[3]); } }
When the following is typed at the command line, what is displayed: java Test Metallica Justice For All 1) All 2) For 3) Justice 4) Nothing.
5) Nothing. An ArrayIndexOutOfBoundsException is thrown Q15 Consider the following piece of code. 1. String s = \
2. Integer x = new Integer(3); 3. String s2 = s + 4; 4. s2 = null; 5. s = null;
Following the execution of which line above, is the object referenced by s2 available for garbage collection. 1) Line 5
2) It is not possible to say when an object is available for garbage collection.
3) Line 4
4) The objects are not available until the executing thread is ended. Q16 What is displayed when the following piece of code is compiled and executed: class Test{
public static void main(String [] args){ Base b = new Subclass(); System.out.println(b.x);
System.out.println(b.method()); } }
class Base{ int x = 2; int method(){ return x; } }
class Subclass extends Base{ int x = 3; int method(){ return x; } }
1) Nothing. The code fails to compile because the object b is not created in a valid way. 2) 2 3 3) 2 2 4) 3 3 5) 3 2
Q17 What is displayed when the following is executed: String s1 = \ s1.concat(\
System.out.println(s1); 1) The string \ 2) The string \
3) Nothing. concat() is not a valid method in the String class. 4) The string \ 5) The string \
Q18 True or False.
The following is a valid way to construct a StringBuffer. StringBuffer sb1 = \ 1) True 2) False
Q19 What is the output of the following piece of code: 1. int x = 6;
2. double d = 7.7; 3.
4. System.out.println((x > d) ? 99.9 : 9);
1) 9 2) 9.0 3) 99.9
4) Nothing. An ArithmeticException is thrown at line 4. 5) 6
Q20 Which of the following can be put in applet tags? (select all the correct answers) 1) CODE 2) WIDTH 3) HEIGHT 4) PARAM 5) ARCHIVE
Q21 What is printed out following the execution of the code below: 1. class Test{
2. static String s;
3. public static void main(String []args){ 4. int x = 4; 5. if (x < 4)
6. System.out.println(\= \+ x); 7. else
8. System.out.println(s); 9. } 10. }
Nothing. The code fails to compile because the String s isn't declared correctly.
1) The text \= null\is displayed. 2) The string \= \is displayed. 3) The text \is displayed. 4) A blank line of text is printed.
Q22 True or False.
The StringBuffer class does not have a concat() method. 1) True 2) False
Q23 What is displayed when the following piece of code is executed (assume the graphics context, g, is correctly set up): g.drawString(\10, 10);
1) The text \with the lower left part of \located at x = 10, y = 10.
2) The text \with the upper left part of \located at x = 10, y = 1
0.
3) Nothing. This is not a valid method. Q24 True or False.
Anonymous classes cannot have constructors. 1) True 2) False
Q25 To reference a JAR from a web page, which of the following keywords are used: 1) jar 2) class 3) zip
4) archive 5) package Q26
Analyse the following 2 classes and select the correct statements. class A{
private int x = 0; static int y = 1;
protected int q = 2; }
class B extends A{ void method(){
System.out.println(x); System.out.println(y); System.out.println(q); } }
1) The code fails to compile because the variable x is not available to class B.
2) The code compiles correctly, and the following is displayed: 0 1 2
3) The code fails to compile because you can't subclass a class with private variables.
4) Removing the line \will allow the code to compile correctly.
5) The compiler will complain that the variable x in class B is undefined. Q27 Which of the following interfaces can be used to manage a collection of elements, with no duplication. 1) List
2) Vector 3) Set
Q28 Which of the following statements are true regarding inner classes. 1) Variables defined inside inner classes cannot be static.
2) Variables defined inside inner classes cannot be static unless the inner class itself is static.
3) Non-static inner classes (which are not defined in a method) have access to all class and instance variables, regardless of the access qualifier of those variables.
4) An inner class can actually be a subclass of the outer class
5) Inner classes can be declared as private. Top level, outer classes cannot.
Q29 Which of the following are valid ways to define an abstract method. 1) abstract void Test(); 2) abstract void Test() {} 3) static abstract void Test(); 4) final abstract void Test();
5) Methods cannot be defined as abstract, only variables can be abstract. Q30 Consider the following: class A extends Integer{ int x = 0; }
Select all valid statements.
1) The code will compile correctly.
2) The code will not compile because Integer is final and cannot be subclassed.
3) The code will not compile because class A has no methods or constructor.
4) The code will compile correctly, but will throw an ArithmeticException at runtime.
Q31 Consider the following and select the correct statement(s): interface A{ int x = 0; A(){ x= 5; }
A(int s){ x = s; } }
1) This is a valid piece of code and it compiles correctly.
2) The default constructor is not required since the compiler will create one for you.
3) The code fails to compile because interfaces cannot have more than 1 constructor.
4) The code fails to compile because an interface cannot have any constructors.
5) The code fails to compile, because a class must have more than 1 character in it's name.
Q32 True or False.
A try block always needs a catch or a finally block (either or both, but not none). 1) True 2) False
Q33 Which of the following are valid ways to declare the main() method which is used to start a Java program. 1) public static void main(String [] args) 2) static public void main(String [] args) 3) public void main(String args [])
4) public static void main(String args[]) 5) public static void main(String args)
Q34 Consider the following piece of code: boolean b = true; System.out.println(b);
What is displayed when this code is executed? 1) The text \is displayed. 2) The text \is displayed
3) The code fails to compile, because conversion string conversion in ths System.out.println() method only applies to integers.
4) The code compiles but nothing is displayed upon execution.
5) The code fails to compile. However, changing the first line to \b = TRUE;\will correctly declare a boolean, and the code will compile and display \
Q35 Which of the following pieces of code compiles without any errors? 1) StringBuffer sb1 = \
2) Boolean b = new Boolean(\ 3) byte b = 255; 4) int x = 0x1234; 5) float fl = 1.2;
Q36 Which of the following are valid statements regarding the following piece of code?
1. String s1 = \
2. StringBuffer sb1 = new StringBuffer(\ 3. int val = 6;
4. System.out.println(s1 + val); 5. System.out.println(sb1 + val);
1) The text \is displayed followed by \
2) The code fails to compile because String conversion does not apply to StringBuffer.
3) The code compiles but upon execution, throws a NullPointerException at line 5.
4) The code fails to compile at line 2, because this is not a valid way to create a StringBuffer.
5) The code fails to compile at line 1, because this is not a valid way to create a String.
Q37 True or False.
Abstract methods can be declared as static. 1) True 2) False
Q38 FlowLayout is the default layout manager for which of the following containers: 1) Panel 2) Applet 3) Frame 4) Window 5) Dialog
Q39 In which class are the following methods defined: - wait() - notify() - notifyAll() 1) Thread 2) Runnable 3) Object 4) Event
5) Synchronize
Q40 Which one of the following creates an instance of Vector with an initial capacity of 10, and an incremental capacity of 5. 1) new Vector(10, 5); 2) new Vector(5,10);
3) None. There is no constructor of Vector which provides this feature. 4) Vector is declared as final, and it is therefore not possible to instantiate
it.
Q41 True of False.
CheckboxGroup is a subclass of Component. 1) True 2) False
Q42 Which statements(s) below are true about the following piece of code.
class Test implements Runnable{
public static void main(String [] args){ Thread t = new Thread(new Test()); t.start(); }
public void run(int limit){
for (int x = 0; x < limit; x++) System.out.println(x); } }
1) All the numbers up to (but not including) \are printed out. 2) Nothing is displayed. There is no explicit call to the run() method.
3) The code fails to compile because the Runnable interface is not implemented correctly.
4) The code can be made to compile by declaring the class Test to be abstract.
5) The code can be made to compile by removing the words \Runnable\
Q43 Consider the following code and select the statement(s) which are true:
1. class Test extends Frame{ 2.
3. public static void main(String [] args){ 4. Test t = new Test(); 5. } 6.
7. Test(){
8. Button b = new Button(\ 9. add(b, BorderLayout.SOUTH); 10. } 11. 12. }
1) The code compiles. When executed, nothing is displayed.
2) The code compiles. When executed, a button with the text \is located at the bottom on the screen. The button is as tall as the text, but is the width of the frame.
3) Adding in the following two lines between lines 9 and 10 will display a frame with a button at the bottom of the frame: setSize(100, 100); setVisible(true);
4) The code fails to compile, because a layout manager was not specified.
5) The code fails to compile because you cannot subclass the Frame class.
Q44 Before which of the following can the keyword \be placed, without causing a compile error. 1) class methods 2) instance methods
3) any block of code within a method 4) variables 5) a class
Q45 Consider the following class definitions: class Base{}
class Subclass1 extends Base{} class Subclass2 extends Base();
Now consider the following declarations: Base b = new Base();
Subclass1 s1 = new Subclass1(); Subclass2 s2 = new Subclass2();
Now, consider the following assignment: s1 = (Subclass1)s2;
Which of the following statements are correct regarding this assignment (select one).
1) The assignment is legal and compiles without an error. No exception is thrown at runtime.
2) The code fails to compile. The compiler complains that the assignment \= (Subclass1)s2\is illegal.
3) The code compiles but ClassCastException is thrown at runtime.
4) The code fails to compile. You cannot subclass a parent class more than once.
Q46 Select all the valid ways of initialising an array. 1) int x[] = {1,2,3};
2) int []x[] = {{1,2,3},{1,2,3}}; 3) int x[3] = {1,2,3}; 4) int []x = {0,0,0};
5) char c[] = {'a', 'b'};
Q47 What is the valid declaration for the finalize() method. 1) protected void finalize() throws Throwable 2) final finalize()
3) public final finalize()
4) private boolean finalize()
5) private final void finalize() throws Exception
Q48 What is the method used to retrieve a parameter passed into an applet using the PARAM tag. 1) getParam() 2) getParameter() 3) getVariable() 4) getVar()
5) There is no method available. You must use \[] args\approach. Q49 You have a button, which is in a panel. The panel is inside a frame. You assign the Frame a 24-point font and a background colour of yellow. You set the panel to have a background colour of red. Which of the following statements are true (select all valid statements). 1) The font size of the button is 24-point.
2) The background colour of the button is the same as that of the frame. 3) The panel has a font size of 8-point.
4) The button inherits the font from the panel.
5) This is not a valid configuration. It is not valid to place a panel into a frame.
Q50 Consider the following piece of code and select the correct statement(s):
public class Test{ final int x = 0; Test(){ x = 1; }
final int aMethod(){ return x; } }
1) The code fails to compile. The compiler complains because there is a final method (\in a non-final class.
2) The code compiles correctly. On execution, an exception is thrown when the Test() constructor is executed.
3) The code fails to compile because an attempt is made to alter the valu
e of a final variable.
4) Removing the \keyword from the line \int x = 0\will allow the code to compile correctly.
5) The code fails to compile because only methods can be declared as final (and therefore \int x = 0\is not valid).
Q51 What is displayed when the following code fragment is compiled and executed (assume that the enveloping class and method is correctly declared and defined):
StringBuffer sb1 = new StringBuffer(\ StringBuffer sb2 = new StringBuffer(\ String s1 = new String(\ String s2 = \
System.out.println(s1==s2); System.out.println(s1=s2);
System.out.println(sb1==sb2);
System.out.println(s1.equals(sb1)); System.out.println(sb1.equals(sb2));
1) The code fails to compile, complaining that the line System.out.println(s1=s2); is illegal.
2) The code fails to compile because the equals() method is not defined for the StringBuffer class. 3) false true true false false 4) false abcd false false false 5) false true false false true
Q52 What is the default layout manager for applets and panels? 1) FlowLayout 2) BorderLayout 3) GridBagLayout 4) GridLayout 5) None of these
Q53 Which of the following statements will compile without an error? 1) Boolean b = new Boolean(\ 2) float f = 123; 3) byte b = 127;
4) int x = (int)(1.23); 5) short s = 128;
Q54 True or False.
Menus can be added to containers. 1) True 2) False
Q55 Which of the following statements are true regarding the graphical methods
paint(), repaint() and update().
1) paint() schedules a call to repaint(). 2) repaint() schedules a call to update(). 3) update() calls paint().
4) update() schedules a call to repaint(). 5) repaint() calls paint() directly.
Q56 To which of the following can a menubar component be added? 1) Applet 2) Panel 3) Frame 4) Canvas
Q57 With regard to apply applet by HTML tags, which of the following statements are correct?
1) The CODE, WIDTH and HEIGHT tags are mandatory and the order is insignificant.
2) CODE and CODEBASE are case insensitive, and the .class extension is optional.
3) The PARAM tag is case insensitive.
4) It is possible to download multiple JAR's with the ARCHIVE tag (eg, ARCHIVE = \, b.jar\
5) The CODE tag is the only mandatory tag.
Q58 Consider the following piece of code and select the correct statements.
1. Object o = new String(\ 2. String s = o;
3. System.out.println(s); 4. System.out.println(o);
1) The following is displayed: abcd abcd
2) The code fails to compile at line 1. 3) The code fails to compile at line 2 4) The code fails to compile at line 4.
5) The code can be made to compile by changing line 1 to the following: String o = new String(\
Q59 Which of the following are legal methods for the String class? 1) length() 2) toUpper()
3) toUpperCase() 4) toString() 5) equals()
Q60 What is the output from the following piece of code: loop1:
for(int i = 0; i < 3; i++){ loop2:
for(int j = 0; j < 3; j++){ if (i == j){ break loop2; }
System.out.print(\= \+ i + \j = \+ j + \\ } } 1) i = 1 j = 0 2) i = 1 j = 0 i = 2 j = 1 3) i = 0 j = 1 i = 0 j = 2 i = 1 j = 0 i = 2 j = 0 i = 2
j = 1 4) i = 1 j = 0 i = 2 j = 0 i = 2 j = 1 5)
i = 1 j = 0 i = 2 j = 0 i = 2 j = 1
Q61 What is displayed when the following piece of code is executed: loop1:
for(int i = 0; i < 3; i++){ loop2:
for(int j = 0; j < 3; j++){ if (i == j){
continue loop2; }
System.out.println(\= \+ i + \j = \+ j); } }
1) i = 0 j = 0 i = 0 j = 1 i = 1 j = 0 i = 1 j = 1 i = 2 j = 0 i = 2 j = 1 2) i = 0 j = 0 i = 1 j = 1 i = 2 j = 2 3) i = 0 j = 1 i = 0 j = 2 i = 1 j = 0 i = 1 j = 2 i = 2 j = 0 i = 2 j = 1
4) None of the above.
Q62 Consider the following piece of code, and select the correct statement(s):
long val = 2; ... ...
Switch (val){
default:
System.out.println(\ break; case 1:
System.out.println(\ break; case 2:
System.out.println(\ case 3:
System.out.println(\ break; }
1) The following is displayed: 2 3
2) The following is displayed: 2
3) The code fails to compile because the default case must be the last case in the switch statement.
4) The code fails to compile because the argument for a switch statement cannot be a variable of type long. 5) The following is displayed: 2 3
Default
Q63 Consider the following piece of code, and select the correct statement(s):
public class Test extends Applet{ public void init(){
setLayout(new GridLayout(1,2)); add(new Button(\ add(new Button(\ add(new Button(\ add(new Button(\ } }
1) The Gridlayout is created with 1 row and 2 columns.
2) Adding the button with the label \will cause an exception to be thrown.
3) Adding the button with label \will cause it to overwrite the button with label \
4) The layout automatically extends to accommodate the additional button
s.
5) Only 2 buttons are displayed, one with label \and one with label \#4\
Q64 Which of the following layout managers will retain the preferred width and height of the contained components. 1) GridLayout 2) GridBagLayout 3) BoxLayout 4) FlowLayout 5)BorderLayout
Q65 You construct a List by calling List(5, false).
Which statements below are correct (assume the layout managers do not modify the List properties).
1) The list supports multiple selection. 2) The list has 5 visible items.
3) A vertical scroll bar will be added automatically if needed.
4) The code fails to compile. The given constructor is not a valid one. Q66 Which of the following will definitely stop a thread from executing: 1) wait() 2) notify() 3) yield() 4) suspend() 5) sleep()
Q67 Which of the following is the correct method to call to change the layout manager for a container: 1) setLayoutManager() 2) setLayManager() 3) changeLayout()
4) You can't change the layout manager for a container. 5) setLayout()
Q68 Which is the correct way to add a button, referenced by b, to a panel, referenced by p. 1) add(p, b); 2) p.add(b) 3) b.add(p)
4) Buttons can't be added to panels. 5) add(p)
Q69 What is displayed when the following code is compiled and executed: long val = 2;
switch(val){ case 1:
System.out.println(\ case 2:
System.out.println(\ default:
System.out.println(\ }
1) default 2) 2 default
3) The code fails to compile because there are no break statements in the case clauses.
4) The code fails to compile because a long data type is not a valid parameter for a switch statement.
Q70 What is displayed following the execution of the code below: 1. class Test{ 2. String s;
3. public static void main(String []args){ 4. int x = 4; 5. if (x < 4)
6. System.out.println(\= \+ x); 7. else
8. System.out.println(s); 9. } 10. }
1) Nothing. The code doesn't compile because the variable s wasn't initialised.
2) The string \is displayed.
3) The code runs, but a NullPointerException is thrown at line 8.
4) The code compiles. No exception is thrown but nothing is displayed. 5) Nothing. The code doesn't compile because you can't make a static reference to a non-static variable.
Q71 Consider the following piece of code: class Test{ int x; String s; float fl;
boolean [] b = new boolean [5]; public static void main(String []args){ System.out.println(x);
}
4) abstract class Person extends Dependants{ Employee e; }
5) class Dependant implements Employee{ Vector person; }
Q179 Which of the following are valid declarations for a native method. 1) public native void aMethod(); 2) private native String aMethod();
3) private native boolean aMethod(int val){}; 4) public native int aMethod(String test);
5)private native boolean aMethod(boolean flag, Integer val);
Q180 Which of the following are valid ways to define an octal literal of value 17 (octal).
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;
Q181 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.0f; 1) d1 == d2; 2) d1 == x; 3) f == x;
4) d1.equals(d2);
5) None of the above
Q182 Given the following definition: String s = null;
Which code fragment will cause an exception of type NullPointerException to be thrown.
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.
Q183 Which of the following are valid declarations for a 2x2 array of integers.
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];
Q184 Which values of variable x will show \2\ switch(x) {
case 1 :
System.out.println(\1\ case 2 : case 3 :
System.out.println(\2\ default :
System.out.println(\ } 1) 1 2) 2 3) 3 4) 4 5) none
Q185 What is the result of the following code : public class SuperEx { String r; String s;
public SuperEx(String a,String b) { r = a;
s = b; }
public void aMethod() {
System.out.println(\:\+ r); } }
public class NewSuper extends SuperEx { public NewSuper(String a,String b) { super(a,b); }
public static void main(String args []) { SuperEx a = new SuperEx(\ SuperEx b = new NewSuper(\
a.aMethod(); b.aMethod(); }
public void aMethod() {
System.out.println(\:\+ r + \s:\+ s); } }
1) The following is displayed: r:Hi s:Hi
2) Compiler error at the line \b = new NewSuper(\ 3) The following is displayed: r:Hi
r:Hi s:Bart
4) The following is displayed r:Hi s:Tom r:Hi s:Bart
Q186 You have a class with a certain variable and you don't want that variable to be accessible to ANY other class but your own. Your class must be sub-classable.
Which keyword do you add to the variable. 1) private 2) public 3) transient 4) final 5) abstract
Q187 You get this description of a class :
Employee is a person. For every employee, we keep a vector with the working hours, an integer for the salary and a variable that can be true or false whether or not the employee has a company car.
Indicate which of the following would be used to define the class members.
1) Vector 2) Employee 3) Object 4) boolean 5) int
Q188 Which line of code can be inserted in place of the comments, to perform the initialisation described by the comments: public class T { int r; int s;
T(int x, int y) { r = x; s = y; } }
class S extends T { int t;
public S(int x, int y, int z){ // insert here the code
// that would do the correct initialisation // r= x and s= y t=z; } }
1) T(x, y); 2) this(x, y); 3) super(x, y); 4) super(x, y, z); 5) None
Q189 Suppose a MyException should be thrown if Condition() is true, which statements do you have to insert ? 1: public aMethod { 2:
3: if (Condition) { 4: 5: } 6: 7: }
1) throw new Exception() at line 4 2) throw new MyException() at line 4 3) throw new MyException() at line 6 4) throws new Exception() at line 2 5) throws MyException at line 1
Q190 Suppose a NullPointerException is thrown by test(). Which message is displayed? void Method(){ try { test();
System.out.println(\ }
catch (ArrayOutOfBoundsException e) { System.out.println(\ }
finally {
System.out.println(\ }
System.out.println(\ }
1) Message1 2) Message2 3) Message3 4) Message4
5) None of the above.
Q191 Choose the class that can hold multiple equal objects in an ordered way. 1) Map
2) Collection 3) List 4) Set 5) Vector
Q192 Consider the following variables definitions. Float f1 = new Float(\ Float f2 = new Float(\
Double d1 = new Double(\
Which of the following yields a boolean value of true. 1) f1 == f2 2) f1.equals(f2) 3) f2.equals(d1)
4) f2.equals(new Float(\
Q193 What does the getID() method of AWTEvent tell us.
1) Tells us the x and y coords of the mouse at the event time. 2) Tells us which Object the event originated from.
3) Tells us which special keys were pressed at the event time. 4) Tells us the event type.
5) Tells us the how many pixels were between the mouse pointer and text on a Canvas.
Q194 What is the return type of an Eventlistener ? 1) int 2) NULL 3) void 4) boolean 5) Object
百度搜索“70edu”或“70教育网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,70教育网,提供经典综合文库英文 SCJP 模拟题200道附答案在线全文阅读。
相关推荐: