need help in several questions about
java 2 as I am not sure about
them. thanks for help.
1: which two can not directly cause a
thread to stop executing?
a: yield()
b: calling the wait method on an object
c:notify()
d: notifyall()
E: call start() on an object.
2:which one is ture for the thread? chose the best answer.
a: if only one thread is blocked in the wait method of an object, and
another thread executed the notify method on that same object, then
the first thread immediately resumes execution.
b: if a thread is blocked in the wait method of an object, and
another thread executed the notify method on that same object, it is
still possible that the first thread might never resume execution.
c: if a thread is blocked in the wait method of an object, and
another thread executed the notify method on that same object, then
the first thread definity resumes execution as a direct and sole
consequences of the notify call.
d: if two threads are blocked in the wait method of one object, and
another thread executed the notify method on the same object, then
the thread that execution as a direct and sole consequence of the
notify call.
3: given:
public class XXX{
private int x;
private int y;
public void setX(int i){x=i;}
public void setY(int i){y=i;}
public synchronized void setXY(int i){setX(i);setY(i);}
public synchronized boolean check(){return x!=y;}
}
under which conditions will check() return ture when called from a
different class? (chose the best answer)
a: check() can never return ture
b: check() can return ture when setXY is called by multiple threads.
c: check() can return ture when multiple thread call setX and setY
separately.
d: check() can only return ture if XXX is changed to allow x and y to
be set separately.
4: which layout managers can be used for components that need to
resize horizontal, but must remain a fixed size vertically when the
container size change? chose one.
a: GridLayout
b: BorderLayout
c:GridBagLayout
d: GridLayout or BorderLayout
e:GridLayout or GridBagLayout
f:BorderLayout or GridBagLayout
g: GridLayout,BorderLayout or GridBagLayout