网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
单选题
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.
参考答案
参考解析
解析:
暂无解析
更多 “单选题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.” 相关考题
考题
本题中,鼠标在窗口中单击一下,就在单击的位置生成一个小矩形,如果在小矩形上双击鼠标左键,则删除小矩形。 import java.awt.*; import java.awt.event.*; import javax swing.*; class MousePanel extends JPanel extends MouseMo- tionListener {public MousePanel {addMouseListener(new MouseAdapter {public void mousePressed(MouseEvent evt) {int X=evt.getX; int Y=evt.getY; current=find(x,y); if(current0) add(x,y); } public void mouseClicked(MouseEvent evt) {int X=evt.getX; int Y=evt.getY; if(evt.getClickCount=2) {remove(current); } } }); addMouseMotionListener(this); } public void paintComponent(Graphics g) {super.paintComponent; for(int i=0;insquares;i++) draw(g,i); } public int find(int X,int y) (for(int i=0;insquares;i++) if(squares[i].x-SQUARELENGTH/2= x X=squares[i].x+SQuARELENGTH/2 squares[i].Y-SQUARELENGTH/2 =Y y=squares[i].Y+SQUARELENGTH /2) return i ; return-1 ; } public void draw(Graphics g,int i) {g.drawRect(squares[i].X-SQUARE- LENGTH/2。 squares[i].Y-SQUARELENGTH/2, SQUARELENGTH, SQUARELENGTH); } public void add(int X,int Y) {if(nsquaresMAXNSQUARES) {squares[nsquares]=new Point(x,y); current=nsquares ; nsquares++; repaint; } } public void remove(int n) {if(n0 ‖ n=nsquares)return; Nsquares- -; squares[n]=squares[nsquares]; if(current= =n)current= -l; repaint; } public void mouseMoved(MouseEvent evt) {} public void mouseDragged(MouseEvent evt) {} private static final int SQUARELENGTH=10: private static final int MAXNSQUARES=100; private Point[]squares=new Point[MAX- NSQUARES]; private int nsquares=0; private int current=-l; } class MouseFrame. extends JFramc {public MouseFrame {setTitle("java3"); setSize(300,200); addWindowListener(new WindowAdapter {public void windowClosing(WindowEvent e) {System.exit(0); } }); Container contentPane=getContentPane; contentPane.add(MousePanel); } } public class java3 {public static void main(String[]args) {JFrame. frame=new MouseFrame; frame.show; } }
考题
阅读下面实现堆栈类并发控制的部分代码 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()
考题
有以下程序:include using namespace std;class A{public: A(int i,int j) { a=i; b=
有以下程序: #include <iostream> using namespace std; class A { public: A(int i,int j) { a=i; b=j; } void move(int x,int y) { a+=x; b+=y; } void show() { cout<<a<<","<<b<<end1; } private: int a,b; }; class B: private A { public: B(int i,int j): A(i,j) {} void fun() { move(3,5); } void fl () { A::show(); } }; int main() { B d(3,4); d.fun(); d.f1(); return 0; } 程序执行后的输出结果是A.3,4B.6,8C.6,9D.4,3
考题
有以下程序:include using namespace std;class A{private: int x,y;public: void se
有以下程序: #include <iostream> using namespace std; class A { private: int x,y; public: void set (int i,int j) { x=i; y=j; } int get_y() { return y; } }; class box { private: int length,width; A label; public: void set(int 1,int w, int s,int p) { length=1; width=w; label.set(s,p); } int get_area() { return length*width; } }; int main() { box small; small.set(2,4,1,35); cout<<small.get_area()<<end1; return 0; } 运行后的输出结果是( )。A.8B.4C.35D.70
考题
若有以下程序include using namespace std;class A{public: A(int i,int j) {a=i;b=j
若有以下程序 #include <iostream> using namespace std; class A { public: A(int i,int j) { a=i; b=j; } void move(int x, int y) { a+=x; b+=y; } void show() { cout < <a < <" , " <<b<< end1; } private: int a,b; }; class B : private A { public: B(int i,int j) :A(i,j) {} void fun ( ) { move (3, 5); } void f1 ( ) { A::show(); } }; int main ( ) { B d(3,4); d. fun ( ); d.f1(); return 0; } 程序执行后的输出结果是 ( )。A.3,4B.6,8C.6,9D.4,3
考题
请找出下列程序中错误之处 ______。 include classA{private: intx1;protected: int
请找出下列程序中错误之处 ______。#include<iostream.h>class A{private:int x1;protected:int x2;public:int x3;};class B:public A{private:int y1;protected:int y2;public:int y3;void disp(){cout<<x1<<y1<<end1:} //Avoid set(int i) {x2=i;} //B};void main() {B bb;bb.x3=10; //Cbb.y3=10; //D}A.AB.BC.CD.D
考题
为了支持压栈线程与弹栈线程之间的交互与同步,在程序的下画线处依次填入的语句是( )。 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)
考题
includeiostream.hclass A{private:int x,y;public:void f1(int i=0,int j=0){x=i;y=j;}void print(){coutx yendl;}void f1(int i=0){x=i,y=0;}};void main(){A a;a.f1(5);a.print();}
考题
若有以下程序:includeusing namespace std;class A{private:int x;public:int z;void
若有以下程序:#include<iostream>using namespace std;class A {private: int x;public: int z; void setx(int i) { x=i; } int getx () { return x; }}:class B : public A{private: int m;public: int p; void setvalue(int a, int b, int c) { setx(a) ; z=b; m=c; } void display{) { cout<<getx ()<<", "<<z<<", "<<m<<end1; }};int main(){ B obj; obj. setvalue(2,3,4); obj.display(); return 0;} 程序运行以后的输出结果是A.产生语法错误B.2,3,4C.2,2,2D.4,3,2
考题
下列程序中说明的私有成员是 ______。class Location{int x;public: void init(int initX,int initY);private: int y;public: int SetX();Int SetY();A.xB.yC.SetX(),SetY()D.ABC都是
考题
( 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()
考题
以下哪个方法可以用来获得进度条的当前进度值?()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 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 class SyncTest ( private int x; private int y; private synchronized void setX (int i) (x=1;) private synchronized void setY (int i) (y=1;) public 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 setseparately.
考题
现有: public class TestDemo{ private int X-2; static int y=3; public void method(){ final int i=100; int j =10; class Cinner { public void mymethod(){ //Here } } } } 在Here处可以访问的变量是哪些?() A、XB、yC、jD、i
考题
public class SyncTest ( private int x; private int y; private synchronized void setX (int i) (x=1;) private synchronized void setY (int i) (y=1;) public 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.
考题
10. class Inner { 11. private int x; 12. public void setX( int x) { this.x = x; } 13. public int getX() { return x; } 14. } 15. 16. class Outer { 17. private Inner y; 18. public void setY( Inner y) { this.y = y; } 19. public Inner getY() { return y; } 20. } 21. 22. public class Gamma { 23. public static void main( String[] args) { 24. Outer o = new Outer(); 25. Inner i = new Inner(); 26.int n=10; 27. i.setX(n); 28. o.setY(i); 29. // insert code here 30. System.out.println( o.getY().getX()); 31. } 32. } Which three code fragments, added individually at line 29, produce the output 100?()A、 n = 100;B、 i.setX( 100);C、 o.getY().setX( 100);D、 i = new Inner(); i.setX( 100);E、 o.setY( i); i = new Inner(); i.setX( 100);F、 i = new Inner(); i.setX( 100); o.setY( i);
考题
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.
考题
public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } Which two classes use the Shape class correctly?()A、 public class Circle implements Shape { private int radius; }B、 public abstract class Circle extends Shape { private int radius; }C、 public class Circle extends Shape { private int radius; public void draw(); }D、 public abstract class Circle implements Shape { private int radius; public void draw(); }E、 public class Circle extends Shape { private int radius;public void draw() {/* code here */} }F、 public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }
考题
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 SyncTest ( private int x; private int y; private synchronized void setX (int i) (x=1;) private synchronized void setY (int i) (y=1;) public 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 setseparately.
考题
多选题10. class Inner { 11. private int x; 12. public void setX( int x) { this.x = x; } 13. public int getX() { return x; } 14. } 15. 16. class Outer { 17. private Inner y; 18. public void setY( Inner y) { this.y = y; } 19. public Inner getY() { return y; } 20. } 21. 22. public class Gamma { 23. public static void main( String[] args) { 24. Outer o = new Outer(); 25. Inner i = new Inner(); 26.int n=10; 27. i.setX(n); 28. o.setY(i); 29. // insert code here 30. System.out.println( o.getY().getX()); 31. } 32. } Which three code fragments, added individually at line 29, produce the output 100?()An = 100;Bi.setX( 100);Co.getY().setX( 100);Di = new Inner(); i.setX( 100);Eo.setY( i); i = new Inner(); i.setX( 100);Fi = new Inner(); i.setX( 100); o.setY( i);
考题
多选题public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } Which two classes use the Shape class correctly?()Apublic class Circle implements Shape { private int radius; }Bpublic abstract class Circle extends Shape { private int radius; }Cpublic class Circle extends Shape { private int radius; public void draw(); }Dpublic abstract class Circle implements Shape { private int radius; public void draw(); }Epublic class Circle extends Shape { private int radius;public void draw() {/* code here */} }Fpublic abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }
考题
单选题public class SyncTest ( private int x; private int y; private synchronized void setX (int i) (x=1;) private synchronized void setY (int i) (y=1;) public 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.
考题
单选题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.
热门标签
最新试卷