1. class A imple

题目

1. class A implements runable (   2. int i;   3. public void run () (   4. try (   5. thread.sleep(5000);   6. i= 10;   7. ) catch(InterruptedException e) {}   8. )   9. )   10.   11. public class Test {   12. public static void main (string args) (   13. try (   14. A a = new A ();   15. Thread t = new Thread (a);  16. t.start();  17.   18. int j= a.i;   19.   20. ) catch (Exception e) {}   21. )   22. )   Which statement al line 17 will ensure that j=10 at line 19?()

  • A、 a.wait();
  • B、 t.wait();
  • C、 t.join();
  • D、 t.yield();
  • E、 t.notify();
  • F、 a.notify();
  • G、 t.interrupt();
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

下面程序输出的结果为

#include"iostream.h"

class A

{

public:

A( ){cout<<"CLASS A"<<endl;}

~A( ){}

};

class B:public A

{

public:

B( ){cout<<"CLASS B"<<endl;}

~B( ){}

};

void main( )

{

A*p;

p=new B;

B *q;

q=new B;

}

A.CLASS A CLASS B

B.CLASS A CLASS B CLASS B

C.CLASS A CLASS B CLASS A CLASS B

D.CLASS A CLASS B CLASS B CLASS B


正确答案:C
解析:每实例化一个类就要调用其构造函数,结束运行该实例后调用析构函数。注意:类的实例化和构造函数、析构函数的调用方式和何时调用。

第2题:

下面程序输出的结果为( )。 #inClUde”iostream.h” Class A {public: A(){cout<<“CLASS A”<<endl;} ~A()<)}; class B:public A {public: B(){cout<<”CLASSB”<<endl;} ~B(){}}; void main() {A*p; p=new B; B *q; q=new B;}

A.CLASS A CLASS B

B.CLASS A CLASS B CLASS B

C.CLASS A ClASS B

D.CLASS A CLASS B CLASS A CLASS B CLASS B CLASS B


正确答案:C
解析: 本题考查类的继承、类的实例化和构造函数、析构函数的调用方式和何时调用。每实例化一个类就要调用其构造函数,结束运行该实例后调用析构函数。

第3题:

1. Everyone in our class ________ .

A. like singing

B. likes play football

C. like watch TV

D. likes playing games


正确答案:D
1.D【解析】主语是everyone按单数对待,所以 A、C不符合题意,like doing sth.表示“喜欢做某事”,是固定结构.

第4题:

Class TestException  1. public class TestException extends Exception {  2. } Class a:  1. public class a {  2.  3. public String sayHello(String name) throws TestException {  4.  5. if(name == null) {  6. throw new TestException();  7. }  8.  9. return “Hello “+ name;  10. }  11.  12. }  A programmer wants to use this code in an application: 45. A a=new A();  46. System.out.println(a.sayHello(”John”));  Which two are true?()

  • A、 Class a will not compile.
  • B、 Line 46 can throw the unchecked exception TestException.
  • C、 Line 45 can throw the unchecked exception TestException.
  • D、 Line 46 will compile if the enclosing method throws a TestException.
  • E、 Line 46 will compile if enclosed in a try block, where TestException is caught.

正确答案:D,E

第5题:

1. public class Target {  2. private int i = 0;  3. public int addOne() {  4. return ++i;  5. }  6. }  And:  1. public class Client {  2. public static void main(String[] args) {  3. System.out.println(new Target().addOne());  4. }  5. }  Which change can you make to Target without affecting Client?() 

  • A、 Line 4 of class Target can be changed to return i++;
  • B、 Line 2 of class Target can be changed to private int i = 1;
  • C、 Line 3 of class Target can be changed to private int addOne() {
  • D、 Line 2 of class Target can be changed to private Integer i = 0;

正确答案:D

第6题:

下面程序输出的结果为 #include"iostream.h” class A { public: A(){cout<<"CLASSA"<<endl;} ~A() {} }; class B:public A { public: B(){cout<<"CLASS B"<<endl;} ~B(){} }; void main() { A*p; p=new B;

A.CLASS A CLASS B CLASS B CLASS B

B.CLASS A CLASS B CLASS A CLASS B

C.CLASS A CLASS B CLASS B

D.CLASS A CLASS B


正确答案:C

第7题:

An engineer is preparing an implementation plan in which the configuration needs to influence BGP‘s choice of best path.Which of the following is least likely to be used by the configuration in this imple mentation plan?()

A. Weight

B. Origin code

C. AS_Path

D. Local_Pref


参考答案:B

第8题:

下面程序输出的结果为 #include"iostream.h" class A { public: A(){cout<<"CLASSA"<<endl;} ~A() {} }; class B:public A { public: B(){cout<<"CLASSB"<<endl;} ~B() {} }; void main() { A * p; p=new B; B *q; q=new B; }

A.CLASS A CLASS B

B.CLASS A CLASS B CLASS B

C.CLASS A CLASS B CLASS A CLASS B

D.CLASS A CLASS B CLASS B CLASS B


正确答案:C
解析:每实例化一个类就要调用其构造函数,结束运行该实例后调用析构函数。注意:类的实例化和构造函数、析函数的调用方式和何时调用。

第9题:

1. public interface A {  2. public void doSomething(String thing);  3. }  1. public class AImpl implements A {  2. public void doSomething(String msg) { }  3. }  1. public class B {  2. public A doit() {  3. // more code here  4. }  5.  6. public String execute() { 7. // more code here  8. }  9. }  1. public class C extends B {  2. public AImpl doit() {  3. // more code here  4. }  5.  6. public Object execute() {  7. // more code here  8. }  9. }  Which statement is true about the classes and interfaces in the exhibit?() 

  • A、 Compilation will succeed for all classes and interfaces.
  • B、 Compilation of class C will fail because of an error in line 2.
  • C、 Compilation of class C will fail because of an error in line 6.
  • D、 Compilation of class AImpl will fail because of an error in line 2.

正确答案:C

第10题:

1. public class a {  2. public void method1() {  3. try {  4. B b=new b();  5. b.method2();  6. // more code here  7. } catch (TestException te) {  8. throw new RuntimeException(te);  9. }  10. }  11. }  1. public class b {  2. public void method2() throws TestException {  3. // more code here  4. }  5. }  1. public class TestException extends Exception {  2. }  Given:  31. public void method() {  32. A a=new a();  33. a.method1();  34. }  Which is true if a TestException is thrown on line 3 of class b?()

  • A、 Line 33 must be called within a try block.
  • B、 The exception thrown by method1 in class a is not required to be caught.
  • C、 The method declared on line 31 must be declared to throw a RuntimeException.
  • D、 On line 5 of class a, the call to method2 of class b does not need to be placed in a try/catch block.

正确答案:B

更多相关问题