首 页
大学试题
CMS专题
工学
经济学
专升本
法学
教育学
历史学
更多分类
搜索
当前位置:
首页
>
SCJP程序员认证考试
>
问题列表
<单选题> public class TwoThreads { private static Object resource = new Object(); private static void delay(long n) { try { Thread.sleep(n); } catch (Exception e) { System.out.print(”Error “); } } public static void main(String[] args) { System.out.print(”StartMain “); new Thread1().start(); delay(1000); Thread t2 = new Thread2(); t2.start(); delay(1000); t2.interrupt delay(1000); System.out.print(”EndMain “); } static class Thread 1 extends Thread { public void run() { synchronized (resource) { System.out.print(”Startl “); delay(6000); System.out.print(”End1 “); } } } static class Thread2 extends Thread { public void run() { synchronized (resource) { System.out.print(”Start2 “); delay(2000); System.out.print(”End2 “); } } } } Assume that sleep(n) executes in exactly m milliseconds, and all other code executes in an insignificant amount of time. What is the output if the main() method is run?()
解析
<单选题> public class Test { public static void aMethod() throws Exception { try { throw new Exception(); } finally { System.out.println(“finally”); } } public static void main(String args[]) { try { aMethod(); } catch (Exception e) { System.out.println(“exception”); } System.out.println(“finished”); } } What is the result?()
解析
<单选题> 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?()
解析
<单选题> 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?()
解析
<单选题> What is wrong with the following code?() class MyException extends Exception {} public class Qb4ab { public void foo() { try { bar(); } finally { baz(); } catch (MyException e) {} } public void bar() throws MyException { throw new MyException(); } public void baz() throws RuntimeException { throw new RuntimeException(); } }
解析
<多选题>Which four types of objects can be thrown using the throw statement?()
解析
<多选题>Which four can be thrown using the throw statement?()
解析
<单选题>for( int i = min; i
解析
<单选题> 1. public class SimpleCalc { 2. public int value; 3. public void calculate() { value += 7; } 4. } And: 1. public class MultiCalc extends SimpleCalc { 2. public void calculate() { value -= 3; } 3. public void calculate(int multiplier) { 4. calculate(); 5. super.calculate(); 6. value *=multiplier; 7. } 8. public static void main(String[] args) { 9. MultiCalc calculator = new MultiCalc(); 10. calculator.calculate(2); 11. System.out.println(”Value is: “+ calculator.value); 12. } 13. } What is the result?()
解析
<单选题> import java.util.*; public class PQ { public static void main(String[] args) { PriorityQueue pq = new PriorityQueue(); pq.add(”carrot”); pq.add(”apple”); pq.add(”banana”); System.out.println(pq.poll() +”:” + pq.peek()); } } What is the result?()
解析
<单选题> Assuming that the serializeBanana2() and the deserializeBanana2() methods will correctly use Java serialization and given: import java.io.*; class Food {Food() { System.out.print(”1”); } } class Fruit extends Food implements Serializable { Fruit() { System.out.print(”2”); } } public class Banana2 extends Fruit { int size = 42; public static void main(String [] args) { Banana2 b = new Banana2(); b.serializeBanana2(b); // assume correct serialization b = b.deserializeBanana2(b); // assume correct System.out.println(” restored “+ b.size + “ “); } // more Banana2 methods } What is the result?()
解析
<单选题> public class X { public static void main (String[]args) { string s = new string (“Hello”); modify(s); System.out.printIn(s); } public static void modify (String s) { s += “world!”; } } What is the result?()
解析
<单选题> 1. class Pizza { 2. java.util.ArrayList toppings; 3. public final void addTopping(String topping) { 4. toppings.add(topping); 5. } 6. } 7. public class PepperoniPizza extends Pizza { 8. public void addTopping(String topping) { 9. System.out.println(”Cannot add Toppings”); 10. } 11. public static void main(String[] args) { 12. Pizza pizza = new PepperoniPizza(); 13. pizza.addTopping(”Mushrooms”); 14. } 15. } What is the result?()
解析
<多选题> public class Car { private int wheelCount; private String vin; public Car(String vin) { this.vin = vin; this.wheelCount = 4; } public String drive() { return “zoom-zoom”; } public String getInfo() { return “VIN: “+ vin + “wheels: “+ wheelCount; } } And: public class MeGo extends Car { public MeGo(String vin) { this.wheelCount = 3; } } What two must the programmer do to correct the compilation errors?()
解析
<单选题> 11. public void genNumbers() { 12. ArrayList numbers = new ArrayList(); 13. for (int i=0; i<10; i++) { 14. int value = i * ((int) Math.random()); 15. Integer intObj = new Integer(value); 16. numbers.add(intObj); 17. } 18. System.out.println(numbers); 19. } Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbage collection?()
解析
相关标签
大学试题
CMS专题
工学
经济学
专升本
法学
教育学
历史学
管理类
管理学
文学
理学
计算机科学技术
土木建筑工程
高起专
本科
世博会知识竞赛
专科
平时作业2
建筑工程
铁路职业技能鉴定考试
平时作业1
土木工程建筑技能考试
哲学
海船船员考试
水路交通运输技能考试
大连工业大学
资格考试
电力负荷控制员
社会学