This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Get Programming with Java (MEAP only) and have Peggy Fisher on-line!
See this thread for details.
Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

from John Hunt mock-thread suspend and resume  RSS feed

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q. 55
What is the result of compiling and executing the following Java class:

public class ThreadTest extends Thread {
public void run() {
System.out.println("In run");
suspend();
resume();
System.out.println("Leaving run");
}

public static void main(String args []) {
(new ThreadTest()).start();
}
}

1.Compilation will fail in the method main.
2.Compilation will fail in the method run.
3.A warning will be generated for method run.
4.The string "In run" will be printed to standard out.
5.Both strings will be printed to standard out.
6.Nothing will happen.
Select the most appropriate answer.
1) the answer is 4, why not 5? (looks like the thread is never resumed. why?)
2)will we be tested for those deprecated methods?
Thanks

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The answer is 4 and not 5 because: after the thread has called the suspend() method, it is not running, so it can't call the resume() method. Another thread has to do that.
I'm really not sure whether we'll be getting questions on deprecated methods in the real exam or not.
Hope that was helpful.
 
Why is the word "abbreviation" so long? And this ad is so short?
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!