问题:多选题Which of these are keywords in Java?()AdefaultBNULLCStringDthrowsElong
查看答案
问题:单选题public class SwitchTest { public static void main(String[] args) { System.out.println(“value = “ + switchIt(4)); } public static int switchIt(int x) { int j = 1; switch (x) { case 1: j++; case 2: j++; case 3: j++; case 4: j++; case 5: j++; default: j++; } return j + x; } } What is the result?()Avalue = 3Bvalue = 4Cvalue = 5Dvalue = 6Evalue = 7Fvalue = 8
问题:单选题public class X { public object m () { object o = new float (3.14F); object oa = new object [1]; oa[0]= o; o = null; oa[0] = null; return o; } } When is the float object created in line 3, eligible for garbage collection?()AJust after line 5.BJust after line 6.CJust after line 7.DJust after line 8(that is, as the method returns).
问题:多选题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 java.awt.event.DThere exists a class named MouseMotionEvent in package java.awt.event.EThere exists a class named ActionAdapter in package java.awt.event.
问题:单选题Which method in the Thread class is used to create and launch a new thread of execution?()A  Run();B  Start();C  Execute();D  Run(Runnable r);E  Start(Runnable r);F  Execute(Thread t);
问题:多选题Which two create an InputStream and open file the “file.txt” for reading? ()AInputStream in=new FileReader(“file.txt”);BInputStream in=new FileInputStream(“file.txt”);CInputStream in=new InputStreamFileReader (“file.txt”, “read”);DFileInputStream in=new FileReader(new File(“file.txt”));EFileInputStream in=new FileInputStream(new File(“file.txt”));
问题:单选题1. public class ForBar { 2. public static void main(String []args) { 3. int i = 0, j = 5; 4. tp: for (;;) { 5. i ++; 6. for(;;) 7. if(i > --j) break tp; 8. } 9. system.out.printIn(“i = ” + i + “, j = “+ j); 10. } 11. } What is the result?()AThe program runs and prints “i=1, j=0”BThe program runs and prints “i=1, j=4”CThe program runs and prints “i=3, j=4”DThe program runs and prints “i=3, j=0”EAn error at line 4 causes compilation to fail.FAn error at line 7 causes compilation to fail.
问题:多选题Which three are valid declarations of a float? ()AFloat foo = -1;BFloat foo = 1.0;CFloat foo = 42e1;DFloat foo = 2.02f;EFloat foo = 3.03d;FFloat foo = 0x0123;
问题:单选题1) class Person { 2) public void printValue(int i, int j) {/*…*/ } 3) public void printValue(int i){/*...*/ } 4) } 5) public class Teacher extends Person { 6) public void printValue() {/*...*/ } 7) public void printValue(int i) {/*...*/} 8) public static void main(String args[]){ 9) Person t = new Teacher(); 10) t.printValue(10); 11) } 12) } Which method will the statement on line 10 call? ()Aon line 2Bon line 3Con line 6Don line 7
问题:单选题int i = 0; while (true) { if(i==4) { break; } ++i; } System.out.println(“i=”+i); What is the result?()Ai = 0Bi = 3Ci = 4Di = 5ECompilation fails.
问题:单选题20. public float getSalary(Employee e) { 21. assert validEmployee(e); 22. float sal = lookupSalary(e); 23. assert (sal>0); 24. return sal; 25. } 26. private int getAge(Employee e) { 27. assert validEmployee(e); 28. int age = lookupAge(e); 29. assert (age>0); 30. return age; 31. } Which line is a violation of appropriate use of the assertion mechanism?()Aline 21Bline 23Cline 27Dline 29
问题:单选题Which statements, when inserted at the indicated position in the following code, will cause a runtime exception when attempting to run the program?() class A {} class B extends A {} class C extends A {} public class Q3ae4 { public static void main(String args[]) { A x = new A(); B y = new B(); C z = new C(); // insert statement here } }A x = y;B z = x;C y = (B) x;D z = (C) y;E y = (A) y;
问题:单选题public class X { public static void main(String [] args) { try { badMethod(); System.out.print(“A”); } catch (RuntimeException ex) { System.out.print(“B”); } catch (Exception ex1) { System.out.print(“C”); } finally { System.out.print(“D”); } System.out.print(“E”); } public static void badMethod() { throw new RuntimeException(); } } What is the result?()ABDBBCDCBDEDBCDEEABCDEFCompilation fails.
问题:单选题Assuming that the serializeBanana() and the deserializeBanana() methods will correctly use Java serialization and given: import java.io.*; class Food implemertts Serializable {int good = 3;} class Fruit externds Food {int juice = 5;} public class Banana extends Fruit { int yellow = 4; public static void main(String [] args) { Banana b = new Banana(); Banana b2 = new Banana(); b.serializeBanana(b); // assume correct serialization b2 = b.deserializeBanana(); // assume correct System.out.println(”restore “+b2.yellow+ b2.juice+b2.good); } // more Banana methods go here } What is the result?()Arestore 400Brestore 403Crestore 453DCompilation fails.EAn exception is thrown at runtime.
问题:单选题Which gets the name of the parent directory file “file.txt”?()AString name= File.getParentName(“file.txt”);BString name= (new File(“file.txt”)).getParent();CString name = (new File(“file.txt”)).getParentName();DString name= (new File(“file.txt”)).getParentFile();EDirectory dir=(new File (“file.txt”)).getParentDir(); String name= dir.getName();
问题:单选题public class X implements Runnable( private int x; private int y; public static void main(Stringargs) X that = new X(); (new Thread(that)).start(); (new Thread(that)).start(); ) public void run() ( for (;;) ( x++; y++; System.out.printIn(“x=” + x + “, y = ” + y); ) ) What is the result?()AErrors at lines 7 and 8 cause compilation to fail.BThe program prints pairs of values for x and y that might not always be the same on the same line (for example, “x=2, y=1”).CThe program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by “x=1, y=1”).DThe program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears only for once (for example, “x=1, y=1” followed by “x=2, y=2”).
问题:多选题Which two CANNOT directly cause a thread to stop executing? ()AExisting from a synchronized block.BCalling the wait method on an object.CCalling notify method on an object.DCalling read method on an InputStream object.ECalling the SetPriority method on a Thread object.
问题:多选题int I=1, j=0 switch(i) { case 2: j+=6; case 4: j+=1; default: j +=2; case 0: j +=4; } What is the value of j at line 16?()A0B1C2D4E6
问题:填空题3. string foo = “ABCDE”; 4. foo.substring(3); 5. foo.concat(“XYZ”); 6. Type the value of foo at line 6.()
问题:多选题11. public interface Status { 12. /* insert code here */ int MY_VALUE = 10; 13. } Which three are valid on line 12?()AfinalBstaticCnativeDpublicEprivateFabstractGprotected