当前分类: SCJP程序员认证考试
问题:单选题public class ItemTest { private final mt id; public ItemTest(int id) { this.id = id; } public void updateId(int newId) { id = newId; } public static void main(String[] args) { ItemTest fa = new ItemTest(42); fa.updateId(69); System.out.println(f...
查看答案
问题:单选题Which fragment is an example of inappropriate use of assertions? ()A assert (!(map.contains(x))); map.add(x);B if (x 0){}else { assert (x==0); }C public void aMethod(int x) { assert (x 0); }D assert (invariantCondition()); return retval;E switch...
问题:Which of the following statements are legal?() ...
问题:单选题public class Foo { public void main( String[] args ) { System.out.println( “Hello” + args[0] ); } } What is the result if this code is executed with the command line?()A HelloB Hello FooC Hello worldD Compilation fails.E The code does not ru...
问题:多选题class A { } class Alpha { private A myA = new A(); void dolt( A a ) { a = null; } void tryIt() { dolt( myA ); } } Which two statements are correct?()AThere are no instanced of A that will become eligible for garbage collection.BExplicitly se...
问题:单选题10. interface Foo { int bar(); } 11. public class Sprite { 12. public int fubar( Foo foo) { return foo.bar(); } 13. public void testFoo() { 14. fubar( 15. // insert code here 16.); 17. } 18. } Which code, inserted at line 15, allows the class ...
问题:单选题What will be written to the standard output when the following program is run?() public class Q63e3 { public static void main(String args[]) { System.out.println(9 ^ 2); } }A 81B 7C 11D 0E false...
问题:单选题public class X { public static void main (Stringargs) { string s = new string (“Hello”); modify(s); System.out.printIn(s); } public static void modify (String s) { s += “world!”; } } What is the result?()A The program runs and print...
问题:1. class A implements Runnable ( 2. int i; 3. public void ...
问题:单选题public class X { public static void main(String [] args) { try { badMethod(); System.out.print(“A”); } catch (Exception ex) { System.out.print(“C”); } finally { System.out.print(“B”); } System.out.print(“D”); } public static void badMetho...
问题:多选题Which statements concerning the event model of the AWT are true?()AAt most one listener of each type can be registered with a component.BMouse motion listeners can be registered on a List instance.CThere exists a class named ContainerEvent in package j...
问题:Which statement is true for the class java.util.ArrayList?()...
问题:public class ConstOver { public ConstOver (int x, int y, in...
问题:Given the uncompleted code of a class: class Person { S...
问题:Which method is an appropriate way to determine the cosine o...
问题:单选题How can you create a listener class that receives events when the mouse is moved?()A By extending MouseListener.B By implementing MouseListener.C By extending MouseMotionListener.D By implementing MouseMotionListener.E Either by extending MouseMot...
问题:单选题What is the numerical range of a char?()A 0 . . . 32767B 0 . . . 65535C –256 . . . 255D –32768 . . . 32767E Range is platform dependent....
问题:11. public enum Title { 12. MR(”Mr.”), MRS(”Mrs.”), MS(”Ms....
问题:多选题Which two statements are reserved words in Java?()ARunBImportCDefaultDImplement...
问题:单选题public class Test { public static void main(String Args[]) { int i =1, j = 0; switch(i) { case 2: j +=6; case 4: j +=1; default: j +=2; case 0: j +=4; } System.out.println(“j =” +j); } } What is the result? ()A 0B 2C 4D 6E 9F 13...