• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Two theoretical questions from javaprepare

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got these two wrong.

Which of the following statements are true. Select the two correct answers.

1. The wait method defined in the Thread class, can be used to convert a thread from Running state to Waiting state.
2. The wait(), notify(), and notifyAll() methods must be executed in synchronized code.
3. The notify() and notifyAll() methods can be used to signal and move waiting threads to ready-to-run state.
4. The Thread class is an abstract class.

I chose 1,2. The correct answer is 2,3. Why is 1 wrong? wait method causes thread to go from Running to Waiting state, doesn't it? Why is 3 right? notify method causes only 1 thread (not all waiting threads) to go from waiting to runnable, right?

-------------------

Which of these are core interfaces in the collection framework. Select the one correct answer.

1. Tree
2. Stack
3. Queue
4. Array
5. LinkedList
6. Map

I chose 3. The correct answer is 6. Queue extends from Collection, doesn't it? While Map does not. So why is 3 wrong and 6 right?
 
author
Posts: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

1. The wait method defined in the Thread class, can be used to convert a thread from Running state to Waiting state.



The wait() method is defined in the Object class. This is probably the piece of knowledge the question was trying to test.

Henry
 
Sachin Kapoor
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. That solves 1 problem.

Originally posted by Henry Wong:


The wait() method is defined in the Object class. This is probably the piece of knowledge the question was trying to test.

Henry

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
About the second question: For which version of SCJP / Java was this test?

There is indeed an interface Queue, but it was added in Java 5. So if this test was for Java 1.4, then Queue would have been a wrong answer.
 
Sachin Kapoor
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That solves it. Thanks!

Originally posted by Jesper Young:
About the second question: For which version of SCJP / Java was this test?

There is indeed an interface Queue, but it was added in Java 5. So if this test was for Java 1.4, then Queue would have been a wrong answer.

 
Poop goes in a willow feeder. Wipe with this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic