以下哪个方法可以用来获得进度条的当前进度值?()A、public synchronized int getProgress()B、public synchronized void setIndeterminate (boolean indeterminate)C、public synchronized void setProgress(int progress)D、Public final synchronized void incrementProgressBy(int diff)

以下哪个方法可以用来获得进度条的当前进度值?()

  • A、public synchronized int getProgress()
  • B、public synchronized void setIndeterminate (boolean indeterminate)
  • C、public synchronized void setProgress(int progress)
  • D、Public final synchronized void incrementProgressBy(int diff)

相关考题:

指出下列哪个方法与方法public void add(int a){}为合理的重载方法。()A public int add(int a)B public void add(long a)C public void add(int a,int b)D public void add(float a)

阅读下面实现堆栈类并发控制的部分代码 public class DataStack{ private int idx=0; private int[]data=new int[8]; public void push(int i){ . ________________{ data[idx]=i; idx + +; } } } …… } 在程序下画线处填入正确选项是A.synchronizedB.synchronized(this)C.synchronized()D.synchronized(idx)

为了支持压栈线程与弹栈线程之间的交互与同步,在下画线处依次填入的语句是 public class IntStack { private int idx=0; private int[]data=new int[8]; public ______ void push(int i) { data[idx]=i; idx++; ______ } … }A.synchronized() notify()B.synchronized() this.wait()C.synchronized() this.notify()D.synchronized() sleep()

为了支持压栈线程与弹栈线程之间的交互与同步,在程序的下画线处依次填入的语句是( )。 public class IntStack{ private int idx=0; private int[]data=new int[8]; public void push(int i){ data[idx]=i: idx++; … … }A.synchronized notifyB.synchronized this.waitC.synchronized this.notifyD.Serializable sleep

阅读下面实现堆栈类并发控制的部分代码 public class DataStack } private int idx=0; private int[] data=new int[8]; public void push(int i) { ______ { data[idx]=I: idx++; } } … } 程序中下画线处应填入的正确选项是A.synchronizedB.synchronized(this)C.synchronized()D.synchronized(idx)

下面哪个方法是 public void example(){...} 的重载方法?A、private void example( int m){...}B、public int example(){...}C、public void example2(){...}D、public int example(int m, float f){...}

指出下列哪个方法与方法public void add(int a){}为错误的重载方法()A、public int add(int a)B、public void add(long a)C、public int add(long a)D、public void add(float a)

下列哪个选项不是InputStream类中的方法? ( )A.public abstract int read()throws IOExceptionB.public final void writeInt(int v)throws IOExceptionC.public void close()throws IOExceptionD.public int available()throws IOException

( 31 ) 为了支持压栈线程与弹栈线程之间的交互与同步 , 在程序的下划线处依次填入的语句是public class IntStack{private int idx=0;private int[] data=new int[8];public void push(int i){data[idx]=i;idx++;}__________......}A ) synchronized()notify()B ) synchronized()this.wait()C ) synchronized()this.notify()D ) synchronized()sleep()

下列哪些是方法public  int  add (int a)的重载方法?() A、  public  int  add (long a);B、  public  void  add (int a);C、  public void add (long a);D、  public  int  add (float a);

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 Account {   private int balance;   public void setBalance(int b) { balance = b; }  public int getBalance() { return balance; }   public void clearBalance() { balance = 0; }   }   哪一个改变可以使 Account 类线程安全?() A、在第2行加 synchronized 修饰符。B、在第3行加 synchronized 修饰符。C、在第3行、第4行和第6行加 synchronized 修饰符。D、在第4行、第6行和第8行加 synchronized 修饰符。

public class SyncTest {  private int x;  private int y;  private synchronized void setX( int i ) { x = i; }  private synchronized void setY( int i ) { y = i; }  public void setXY( int i ) { setX(i); setY(i); }  public synchronized boolean check() { return x != y; }  }   Under which condition will check return true when called from a different class? () A、 check can never return true.B、 check can return true when setXY is called by multiple threads.C、 check can return true when multiple threads call setX and setY separately.D、 check can return true only if SyncTest is changed to allow x and y to be set separately.

下列方法中,与方法public void add(inta){}为合理重载的方法是()。A、public int add(int a)B、public void add(long a)C、public void add(int a)D、public void add(int a,int b)

public class Parent{     public void change(int x){} }  public class Child extends Parent{     //覆盖父类change方法  }  下列哪个声明是正确的覆盖了父类的change方法?() A、 protected void change(int x){}B、 public void change(int x, int y){}C、 public void change(String s){}D、 public void change(int x){}

Which three will compile and run without exception?()A、private synchronized Object o;B、void go(){   synchronized(){/* code here */}C、public synchronized void go(){/* code here */}D、private synchronized(this) void go(){/* code here */}E、void go(){   synchronized(Object.class){/* code here */}F、void go(){   Object o = new Object();   synchronized(o){/* code here */}

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() { coount++; }  public int getCount() { return count; } public void reset() { count = 0; } }  Which three changes should be made to adapt this class to be used safely by multiple threads? ()A、 declare reset() using the synchronized keywordB、 declare getName() using the synchronized keywordC、 declare getCount() using the synchronized keywordD、 declare the constructor using the synchronized keywordE、 declare increment() using the synchronized keyword

public class TestSeven extends Thread {  private static int x;  public synchronized void doThings() {  int current = x;  current++;  x = current;  }  public void run() {  doThings();  }  }  Which is true?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 Synchronizing the run() method would make the class thread-safe.D、 The data in variable “x” are protected from concurrent access problems.E、 Declaring the doThings() method as static would make the class thread-safe.F、 Wrapping the statements within doThings() in a synchronized(new Object()) {} block would make the class thread-safe.

public class SyncTest {  private int x;  private int y;  public synchronized void setX (int i) (x=1;)  public synchronized void setY (int i) (y=1;)  public synchronized void setXY(int 1)(set X(i); setY(i);)  public synchronized Boolean check() (return x !=y;)  }  Under which conditions will check () return true when called from a different class?A、 Check() can never return true.B、 Check() can return true when setXY is called by multiple threads.C、 Check() can return true when multiple threads call setX and setY separately.D、 Check() can only return true if SyncTest is changed to allow x and y to be set separately.

class Computation extends Thread {  private int num;  private boolean isComplete;  private int result;  public Computation(int num) { this.num = num; }  public synchronized void run() {  result = num * 2;  isComplete = true;  notify();  }  public synchronized int getResult() {  while (!isComplete) {  try {  wait();  } catch (InterruptedException e) { }  }  return result;  }  public static void main(String[] args) {  Computation[] computations = new Computation [4];  for (int i = 0; i  computations.length; i++) {  computations[i] = new Computation(i);  computations[i] .start();  }  for (Computation c : computations)  System.out.print(c.getResult() +“ “);  }  }  What is the result?() A、 The code will deadlock.B、 The code may run with no output.C、 An exception is thrown at runtime.D、 The code may run with output “0 6”.E、 The code may run with output “2 0 6 4‟.F、 The code may ruin with output “0 2 4 6”.

public class TestFive {  private int x;  public void foo() {  int current = x;  x = current + 1;  }  public void go() {  for(int i=0;i5;i++) {  new Thread() {  public void run() {  foo();  System.out.print(x + “, “);  } }.start();  }}}  Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5, ?()A、 Move the line 12 print statement into the foo() method.B、 Change line 7 to public synchronized void go() {.C、 Change the variable declaration on line 3 to private volatile int x;.D、 Wrap the code inside the foo() method with a synchronized( this ) block.E、 Wrap the for loop code inside the go() method with a synchronized block synchronized(this) { // for loop code here }.

多选题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.

多选题import java.util.*;  public class NameList {  private List names = new ArrayList();  public synchronized void add(String name) { names.add(name); }  public synchronized void printAll() {  for (int i = 0; i System.out.print(names.get(i) +“ “); }  }  public static void main(String[] args) {  final NameList sl = new NameList();  for(int i=0;iAAn exception may be thrown at runtime.BThe code may run with no output, without exiting.CThe code may rum with output “A B A B C C “, then exit.DThe code may ruin with output “A A A B C A B C C “, then exit.EThe code may rum with output “A B C A B C A B C “, then exit.FThe code may ruin with output “A B C A A B C A B C “, then exit.

多选题public class TestFive {  private int x;  public void foo() {  int current = x;  x = current + 1;  }  public void go() {  for(int i=0;i5;i++) {  new Thread() {  public void run() {  foo();  System.out.print(x + “, “);  } }.start();  }}}  Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5, ?()AMove the line 12 print statement into the foo() method.BChange line 7 to public synchronized void go() {.CChange the variable declaration on line 3 to private volatile int x;.DWrap the code inside the foo() method with a synchronized( this ) block.EWrap the for loop code inside the go() method with a synchronized block synchronized(this) { // for loop code here }.

单选题现有      public class Parentt      public void change (int x){)     )      public class Child extends Parent{     //覆盖父类change方法     }      下列哪个声明是正确的覆盖了父类的change方法?()A  protected void change (int x){}B  public void change(int x,  int y){}C  public void change (int x){}D  public void change (String s){}

单选题以下哪个方法可以用来获得进度条的当前进度值?()Apublic synchronized int getProgress()Bpublic synchronized void setIndeterminate (boolean indeterminate)Cpublic synchronized void setProgress(int progress)DPublic final synchronized void incrementProgressBy(int diff)

单选题class Account {   private int balance;   public void setBalance(int b) { balance = b; }  public int getBalance() { return balance; }   public void clearBalance() { balance = 0; }   }   哪一个改变可以使 Account 类线程安全?()A在第2行加 synchronized 修饰符。B在第3行加 synchronized 修饰符。C在第3行、第4行和第6行加 synchronized 修饰符。D在第4行、第6行和第8行加 synchronized 修饰符。