JAVA 部分
1.which are run-time exceptions() A.ArithmeticException B.ClassNotFoundException C.OutOfMemoryError D.ClassCastException E.InterruptedException F.IllegalArgumentException G.IndexOutOfBoundsException H.NullPointException a,d,f,g,h
2.Which Man class properly represents the relationship "Man has a best friend who is a Dog" d A.class Man extends Dog{} B.class Man implements{} C.class Man{private BestFriend dog;} D.class Man{private Dog bestFriend;} E.class Man{private Dog;} F.class Man{private BestFriend;}
3 Given: b,c,f interface Jumper{public void jump();} class Animal{}.. class Dog extends Animal{Tail tail;} class Beagle extends Dog implements Jumper{public void jump(){}}.. class Cat implements Jumper(public void jump(){}} Which are true( ) Multiple choices A.Cat is-a Aminal B.Cat is-a Jumper C.Dog is-a Animal D.Dog is-a Jumper E.Cat has-a Animal F.Beagle has-a Tail H.Beagle has-a Jumper 4 Given: a,b,c,d,e interface A{public int getValue();} class B implements A{public int getValue(){return 1;}} class C extends B{ 15 :insert code in here}
Which three code frgments,inserted individaully at line 15,make use (多选) A:public void add(C c){c.getValue();} B:public void add(B b){b.getValue();} C:public void add(A a){a.getValue();} D:public void add(A a,B b){a.getValue();} E:public void add(C c1,C c2){c1.getValue();}
5.丢失 丢失 6.Given B [2P]
String test = "This is test"; String[] tokens = test.split("¥s"); System.out.println(tokens.length); whta is the result( ) A.0 B.1 C.4 D.Compilation fails E.An exception is thrown at runtime
7. Given: C class Wow{ public static void go(short n){ System.out.print("short"); } public static void go(Short n){ System.out.print("SHORT"); } public static void go(Long n){ System.out.print("LONG"); } public static void main(String[] args){ Short n = 6; int m = 7; go(n); go(m); } } Which is th result? ( A. short LONG ) [2P]
B. SHORT LONG C. Compilation fails D.An exception is thrown at runtime 8.public class NamedCounter{ private final String name; private int count; public NamedCounter(String name){ this.name = name; } public String getName(){ return name; } public void increment(){ count++; } public int getCount(){ return count; } public void reset(){ count = 0; } } Which changes should be made to adapt this class to be used savely by threads? a,b,c,e [Multiple choices] A.declare reset() using the synchronized keyword B.declare getName() using the synchronized keyword C.declare getCount() using the synchronized key
word D.declare the constructor using the synchronized keyword E.declare increment() using the synchronized keyword 9、Which two statements are true?( ) [2P] 、 (Choose two) A.It is poossible for more than two threads to deadlock at once. B.The JVM implementation guarantees that multiple threads cannot enter into a deadlocked state. C.Deadlocked threads release once their sleep() method's sleep duration has expired. D.Deadlocking can occur only when the wait(),notify(),and notifyAll(
) methods are use incorrectly. E.(看不到) F.(看不到) ( )[2P]
10.Given: b, Interface Foo{} class Alpha implements Foo{} class Beta extends Alpha {} class Delta extends Beta{ public static void main(String[] args){ Beta x=new Beta(); 16.//insert code here } } Which code,inserted at line16,will cause a java.lang.ClassCastException ( ) A.Alpha a=x; B.Foo f=(De