• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

some intersting questions

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi im not clear about the first two queations
in the second question im not sure whether the first thread will start execution when one calls notify(). In my opinion it should.
Third question answer is c it cannot be d because we dont have to make any changes in XXX bcoz both are public.
someone please confirm about first two questions with reasons
Cherry
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
vis,
you are doing good to concentrate on threads.
for question one I would say c and d. calling start() might stop a thread if the thread you are calling start() on has a higher priority.
question 2 a and c are not really true. I would choose answer b since answer d makes no sense.
question 3 I agree with cherry it is answer c.
question 4 I say answer c or f. it is a tricky question,
in Border layout, Components are resized horizontally but not vertically, (only)if they are placed in the north or south. so answer is probably c.
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
calling a wait() on an object will also stop the thread executing right?. So why not choice b) be included?
 
Cherry Mathew
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These are good questions
cant we have a good discussiona botu these qusetions
Jane,Bill,Tom,Ajith please comment
regards
Cherry
reply
    Bookmark Topic Watch Topic
  • New Topic