网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
多选题
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?()
A

The output may be “r1 = 6, r2 = 14”.

B

The output may be “r1 = 5, r2 = 15”.

C

The output may be “r1 = 8, r2 = 12”.

D

The code may run (and complete) with no output.

E

The code may deadlock (without completing) with no output.

F

M IllegalStateException or InterruptedException may be thrown at runtime.


参考答案

参考解析
解析: 暂无解析
更多 “多选题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.” 相关考题
考题 publicclassTransfers{publicstaticvoidmain(String[]args)throwsException{Recordr1=newRecord();Recordr2=newRecord();doTransfer(r1,r2,5);doTransfer(r2,r1,2);doTransfer(r1,r2,1);//printtheresultSystem.out.println(”rl=+r1.get()+,r2=”+r2.get());}privatestaticvoiddoTransfer(finalRecorda,finalRecordb,finalintamount){Threadt=newThread(){publicvoidrun(){newClerk().transfer(a,b,amount);}};t.start();}}classClerk{publicsynchronizedvoidtransfer(Recorda,Recordb,intamount){synchronized(a){synchronized(b){a.add(-amount);b.add(amount);}}}}classRecord{intnum=10;publicintget(){returnnum;}publicvoidadd(intn){num=num+n;}}IfTransfers.main()isrun,whichthreearetrue?()

考题 有以下程序:includeusing namespace std;{public:TestClass(int r1,int r2){R1=r1;R2 有以下程序: #include<iostream> using namespace std; { public: TestClass(int r1,int r2) { R1=r1; R2=r2; } void print(); void print() const; private; int R1,R2; }; void TestClass::print() { cout<<R1<<","<<R2<<end1; } void Testclass::print() const cout<<R1<<","<<R2<<end1; } int main() { TestClass a(5,4); const TestClass b(20,52); b.print(); return 0; } 执行后的输出结果是( )。A.5,4B.20,52C.0,0D.4,5

考题 有以下程序:includeusing namespace std;class R{ public: R(int r1,int r2) {R1=r1; 有以下程序: #include<iostream> using namespace std; class R { public: R(int r1,int r2) { R1=r1; R2=r2; } void print(); void print()const; private: int R1,R2; }; void R::print() { cout<<R1<<","<<R2<<end1; } void R::print()const { cout<<R1<<","<<R2<<end1; } int main() { R a(5,4); const R b(20,52); b.print(); return 0; } 执行后的输出结果是( )。A.5,4B.4,5C.20,52D.52,20

考题 有以下程序:includeusing namespace std;class R{public:R(int r1,int r2){R1=rl;R2= 有以下程序: #include<iostream> using namespace std; class R { public: R(int r1,int r2) { R1=rl; R2=r2; } void print(); void print()const; private: int R1,R2; }; void R::print() { cout<<R1<<","<<R2<<end1; } void R::print() const { cot<<R1<<","<<R2<<end1; } int main() { Ra(5,4); const R b(20,52); b.print(); return 0; } 执行后的输出结果是A.5,4B.20,52C.0,0D.4,5

考题 有以下程序:includeusing namespace std;class R{public:R(int r1,int r2){R1=r1;R2= 有以下程序: #include<iostream> using namespace std; class R { public: R(int r1,int r2) { R1=r1; R2=r2; } void print(); void print0const; private: int R1,R2; }; void R::print() { cout<<R1<<","<<R2<<endl; } void R::print() const { cout<<Rl<<","<<R2<<endl; } int main() { R a(5,4); const R b(20,52); b.print(); return 0; } 执行后的输出结果是( )。A.5,4B.20,52C.0,0D.4,5

考题 有以下程序;include using namespace std;class R{public:R(int r1,int r2){R1=r1;R2 有以下程序; #include <iostream> using namespace std; class R { public: R(int r1,int r2) { R1=r1; R2=r2; } void print(); void print () const; private: int R1, R2; }; void R::print () { cout<<R1<<","<<R2<<endl; } void R::print() const { cout<<R1<<", "<<R2<<endl; } int main () { R a(5,4); const R b(20,52); b.print(); return 0; } 执行后的输出结果是A.5,4B.20,52C.0,0D.4,5

考题 有以下程序:include using namespace std;class R{public: R(int f1,int r2) {R1=r1; 有以下程序: #include <iostream> using namespace std; class R { public: R(int f1,int r2) { R1=r1; R2=r2; } void print(); void print ()const; private: int R1, R2; }; void R: :print() { cout<<R1<<", "<<R2<<end1; } void R: :print() const { cout<<Rl<<", "<<R2<<end1; } int main () { R a(5,4); const R b(20,52); b.print (); return 0; } 执行后的输出结果是A.5,4B.20,52C.0,0D.4,5

考题 听力原文:[解析] 有以下程序:includeusing namespace Std;Class R{public:R(int r1,i 听力原文:[解析]有以下程序: #include<iostream> using namespace Std; Class R {public: R(int r1,int r2) {R1=r1; R2=r2;} void print(); void print()const; private: int R1,R2;}; roid R::print() {cout<<R1<<“,”<<R2<<endl;} void R::print()conA.5,4B.20,52C.0,0D.4,5

考题 有以下程序 include using namespace std; class R{ public: R(int r1,int r2){R1=r 有以下程序#include <iostream>using namespace std;class R{public:R(int r1,int r2){R1=r1;R2=r2;}void print();void print()const;private:iht R1,R2;};A.5,4B.20,52C.0,0D.4,5

考题 有阻值分别为R1和R2的两个负载,其中R1的电阻值是R2的N倍,把它们并联后接到电源上,则:(”x^m”表示“x的m次方”)()A、流过R1的电流是R2的N倍,R1消耗的功率是R2的N^2倍B、流过R1的电流是R2的1/N,R1消耗的功率是R2的1/NC、流过R1的电流与R2的相同,R1消耗的功率是R2的1/N^2D、流过R1的电流与R2的相同,R1消耗的功率是R2的N倍

考题 有阻值分别为R1和R2的两个负载,其中R1的电阻值是R2的N倍,把它们并联后接到电源上,则:(”x^m”表示“x的m次方”)()A、R1两端的电压与R2的相同,R1消耗的功率是R2的1/NB、R1两端的电压与R2的相同,R1消耗的功率是R2的N^2倍C、R1两端的电压是R2的1/N,R1消耗的功率是R2的1/N^2D、R1两端的电压是R2的N倍,R1消耗的功率是R2的N^2倍

考题 计算题:两个电阻R1和R2并联连接,当R1和R2具有下列数值时,试求并联的等效电阻。①R1=R2=2Ω;②R1=2Ω,R2=0。

考题 Routers R1 and R2 are EIGRP neighbors. R1 has been configured with the eigrp stub connected command. Which of the following is true as a result?()A、R1 can learn EIGRP routes from R2, but R2 cannot learn EIGRP routes from R1B、R1 can send IP packets to R2, but R2 cannot send IP packets to R1C、R2 no longer learns EIGRP routes from R1 for routes not connected to R1D、R1 no longer replies to R2's Query messagesE、R2n o longer sends to R1 Query messages

考题 Two directly connected routers, R1 and R2, are both configured for OSPF graceful restart. R2 is able to switch packets in hardware, but R1 is not. If a network administrator logs on to R2 and performs a system reload, which will be the result?()A、Traffic forwarded from R2 to or through R1 will continue to be forwarded based on the forwarding table state at the time of the reload.B、R2 will continue to forward traffic to R1, but R1 will drop the traffic because its neighbor adjacency with R2 has failed.C、R2 will continue forwarding traffic to and through R1, but R1 will drop this traffic because it is not capable of maintaining its forwarding state.D、All the traffic R2 is forwarding to or through R1 will be dropped while OSPF rebuilds its neighbor adjacency and forwarding tables.

考题 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?()A、 The output may be “r1 = 6, r2 = 14”.B、 The output may be “r1 = 5, r2 = 15”.C、 The output may be “r1 = 8, r2 = 12”.D、 The code may run (and complete) with no output.E、 The code may deadlock (without completing) with no output.F、 M IllegalStateException or InterruptedException may be thrown at runtime.

考题 class TestA {  public void start() { System.out.println(”TestA”); }  }  public class TestB extends TestA {  public void start() { System.out.println(”TestB”); } public static void main(String[] args) {  ((TestA)new TestB()).start();  }  }  What is the result?() A、 TestAB、 TestBC、 Compilation fails.D、 An exception is thrown at runtime.

考题 极性最大的是()A、R1=β-D-洋地黄毒糖-β-D葡萄糖,R2=甲基B、R1=氢,R2=醛基C、R1=α-L鼠李糖,R2=醛基D、R1=α-L鼠李糖-β-D葡萄糖,R2=甲基E、R1=氢,R2=甲基

考题 以下ARM指令中不属于数据处理类指令的是()A、ADC R1,R2,R3B、LDR R1,[R2]C、MOV R1,R2,LSL#4D、ORR R1,R2,R3

考题 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?()  A、 finallyB、 exception finishedC、 finally exception finishedD、 Compilation fails.

考题 public class Threads 1 {  intx=0;  public class Runner implements Runnable {  public void run() {  int current = 0;  for(int=i=0;i4;i++){  current = x;  System.out.print(current + “, “);  x = current + 2;  }  }  }  public static void main(String[] args) {  new Threads1().go();  }  public void go() {  Runnable r1 = new Runner();  new Thread(r1).start();  new Thread(r1 ).start();  }  }  Which two are possible results?()A、 0, 2, 4, 4, 6, 8, 10, 6,B、 0, 2, 4, 6, 8, 10, 2, 4,C、 0, 2, 4, 6, 8, 10, 12, 14,D、 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14,E、 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14,

考题 public class Starter extends Thread {  private int x= 2;  public static void main(String[] args) throws Exception {  new Starter().makeItSo();  }  public Starter() {  x=5;  start();  }  public void makeItSo() throws Exception {  join();  x=x- 1;  System.out.println(x);  }  public void run() { x *= 2; }  }  What is the output if the main() method is rum?() A、 4B、 5C、 8D、 9E、 Compilation fails.F、 An exception is thrown at runtime.G、 It is impossible to determine for certain.

考题 电阻R1,R2并联,已知R1>>R2,并联后的等值电阻近似等于R1,即R≈R1。

考题 两个电阻R1和R2做串联连接,当R1和R2具有以下数值时,试求串联的等效电阻: ①R1=R2=1Ω;②R1=3Ω,R2=6Ω。

考题 单选题以下不能完成将R2中数值的两倍写入R1中的ARM指令是()A ADD R1,R2,R2B ORR R1,R2,R2C MOV R1,R2,LSL#1D MUL R1,R2,#2

考题 单选题Two directly connected routers, R1 and R2, are both configured for OSPF graceful restart. R2 is able to switch packets in hardware, but R1 is not. If a network administrator logs on to R2 and performs a system reload, which will be the result?()A Traffic forwarded from R2 to or through R1 will continue to be forwarded based on the forwarding table state at the time of the reload.B R2 will continue to forward traffic to R1, but R1 will drop the traffic because its neighbor adjacency with R2 has failed.C R2 will continue forwarding traffic to and through R1, but R1 will drop this traffic because it is not capable of maintaining its forwarding state.D All the traffic R2 is forwarding to or through R1 will be dropped while OSPF rebuilds its neighbor adjacency and forwarding tables.

考题 多选题public class Threads 1 {  intx=0;  public class Runner implements Runnable {  public void run() {  int current = 0;  for(int=i=0;i4;i++){  current = x;  System.out.print(current + “, “);  x = current + 2;  }  }  }  public static void main(String[] args) {  new Threads1().go();  }  public void go() {  Runnable r1 = new Runner();  new Thread(r1).start();  new Thread(r1 ).start();  }  }  Which two are possible results?()A0, 2, 4, 4, 6, 8, 10, 6,B0, 2, 4, 6, 8, 10, 2, 4,C0, 2, 4, 6, 8, 10, 12, 14,D0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14,E0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14,

考题 单选题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?()A  finallyB  exception finishedC  finally exception finishedD  Compilation fails.