问题:单选题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”).
Thursday, September 22, 2022
问题:填空题3. string foo = “ABCDE”; 4. foo.substring(3); 5. foo.concat(“XYZ”); 6. Type the value of foo at line 6.()
Tuesday, September 17, 2024
问题:单选题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.
问题:多选题Which two valid declarations of a char? ()AChar ch = “a”;BChar ch = ‘“‘ ‘;CChar ch = ‘cafe‘;DChar ch = “cafe”;EChar ch = ‘“ucafe‘;FChar ch = ‘“u10100‘;GChar ch = (char) true;
问题:多选题Which of these are keywords in Java?()AdefaultBNULLCStringDthrowsElong
问题:单选题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.
Monday, September 9, 2024
问题:多选题class One { void foo() {} } class Two extends One { //insert method here } Which three methods, inserted individually at line 14, will correctly complete class Two?()Aint foo() { /* more code here */ }Bvoid foo() { /* more code here */ }Cpublic void foo() { /* more code here */ }Dprivate void foo() { /* more code here */ }Eprotected void foo() { /* more code here */ }
Saturday, September 17, 2022
问题:单选题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.
问题:单选题Given the fully-qualified class names: com.foo.bar.Dog com.foo.bar.blatz.Book com.bar.Car com.bar.blatz.Sun Which graph represents the correct directory structure for a JAR file from which those classes can be used by the compiler and JYM?()AJar ABJar BCJar CDJar DEJar E
问题:单选题public class ExceptionTest { class TestException extends Exception {} public void runTest () throws TestException {} public void test () /* Point X*/ { runTest (); } } At point X on line 4, which code can be added to make the code compile?()AThrows Exception.BCatch (Exception e).CThrows RuntimeException.DCatch (TestException e).ENo code is necessary.
Monday, October 2, 2023
问题:单选题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).
问题:多选题11. public interface Status { 12. /* insert code here */ int MY_VALUE = 10; 13. } Which three are valid on line 12?()AfinalBstaticCnativeDpublicEprivateFabstractGprotected
Thursday, October 5, 2023
问题:单选题static void test() throws Error { if (true) throw new AssertionError(); System.out.print(”test “); } public static void main(String[] args) { try { test(); } catch (Exception ex) { System.out.print(”exception “); } System.out.print(”elld “); } What is the result?()AendBCompilation fails.Cexception endDexception test endEA Throwable is thrown by main.FAn Exception is thrown by main.
Sunday, March 12, 2023
问题:单选题11.classA { 12. public void process() { System.out.print(”A “); } } 13. class B extends A { 14. public void process() throws RuntimeException { 15. super.process(); 16. if (true) throw new RuntimeException(); 17. System.out.print(“B”); }} 18. public static void main(String[] args) { 19. try { ((A)new B()).process(); } 20. catch (Exception e) { System.out.print(”Exception “); } 21. } What is the result?()AExceptionBA ExceptionCA Exception BDA B ExceptionECompilation fails because of an error in line 14.FCompilation fails because of an error in line 19.
问题:单选题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();
Thursday, January 18, 2024
问题:多选题public class Transfers { public static void main(String[] args) throws Exception { Record r1 = new Record(); Record r2 = new Record(); doTransfer(r1, r2, 5); doTransfer(r2, r1, 2); doTransfer(r1, r2, 1); // print the result System.out.println(”rl = “ + r1.get() +“, r2=” + r2.get()); } private static void doTransfer( final Record a, final Record b, final int amount) { Thread t = new Thread() { public void run() { new Clerk().transfer(a, b, amount); } }; t.start(); } } class Clerk { public synchronized void transfer(Record a, Record b, int amount){ synchronized (a) { synchronized (b) { a.add(-amount); b.add(amount); } } } } class Record { int num=10; public int get() { return num; } public void add(int n) { num = num + n; } } If Transfers.main() is run, which three are true?()AThe output may be “r1 = 6, r2 = 14”.BThe output may be “r1 = 5, r2 = 15”.CThe output may be “r1 = 8, r2 = 12”.DThe code may run (and complete) with no output.EThe code may deadlock (without completing) with no output.FM IllegalStateException or InterruptedException may be thrown at runtime.
Friday, December 13, 2024
问题:多选题switch (i) { default: 310-025 Leading the way in IT testing and certification tools,www.testking.com - 27 - System.out.printIn(“Hello”); } What are the two acceptable types for the variable i? ()ACharBByteCFloatDDoubleEObject
Friday, December 27, 2024
问题:多选题public class Threads2 implements Runnable { public void nun() { System.out.println(”run.”); throw new RuntimeException(”Problem”); } public static void main(String[] args) { Thread t = new Thread(new Threads2()); t.start(); System.out.println(”End of method.”); } } Which two can be results?()Ajava.lang.RuntimeException: ProblemBrun. java.lang.RuntimeException: ProblemCEnd of method. java.lang.RuntimeException: ProblemDEnd of method. run. java.lang.RuntimeException: ProblemErun. java.lang.RuntimeException: Problem End of method.
Sunday, September 18, 2022
问题:单选题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;
Tuesday, September 5, 2023
问题:多选题Which two are equivalent?()A3/2B3<2C3*4D3<<2E3*2^2F3<<<2
Wednesday, February 21, 2024