Java 2 Exam Notes (Programmer's Exam)

Overview

Java 2 Exam Notes is the fastest and most effective way to make sure you're ready to pass the Java 2 Programmer's Exam.

The unique, innovative Exam Notes approach helps you gain and retain the knowledge you need, objective by objective:
* Critical Information sections provide detailed analyses of the key issues for each exam objective.
* ...

See more details below
Paperback
$25.42
BN.com price
(Save 5%)$26.95 List Price
Other sellers (Paperback)
  • All (12) from $1.99   
  • New (5) from $15.85   
  • Used (7) from $1.99   
Sending request ...

Overview

Java 2 Exam Notes is the fastest and most effective way to make sure you're ready to pass the Java 2 Programmer's Exam.

The unique, innovative Exam Notes approach helps you gain and retain the knowledge you need, objective by objective:
* Critical Information sections provide detailed analyses of the key issues for each exam objective.
* Exam Essentials sections highlight crucial subject areas you'll need to know for the exam.
* Key Terms and Concepts sections define the words and concepts vital to passing the exam.
* Sample Questions sections preview the types of questions found on the exam and give answers and explanations.

Get Ready for the Exam with the Complete Java 2 Certification Study Guide
* In-Depth Coverage of the Programmer's and Developer's Exams

A companion to the Sybex study guide for Java 2, this volume reinforces the reader&#39s knowledge and helps when preparing for the Java 2 programmer&#39s exam. Provides sample questions, defines key terms and concepts, and reviews all of the fundamentals needed to pass the exam. Softcover.

Read More Show Less

Product Details

  • ISBN-13: 9780782128260
  • Publisher: Wiley
  • Publication date: 12/5/2000
  • Edition number: 1
  • Pages: 258
  • Product dimensions: 8.50 (w) x 5.50 (h) x 0.65 (d)

Meet the Author

Philip Heller, is a lead consultant in the Java industry. He is a dynamic speaker and educator who has taught courses in the Java University at Sun Mircrosystems Java events around the US. An authority on Java Certification, he has coauthored the best-selling Complete Java 2 Certification Study Guide from Sybex.

Read More Show Less

Read an Excerpt

7: Threads

Sun Certified Programmer for the Java 2 platform exam objectives covered in this chapter:
  • Write code to define, instantiate, and start new threads using both java.lang.Thread and java.lang.Runnable.
  • Recognize conditions that might prevent a thread from executing.
  • Write code using synchronized, wait, notify, and notifyAll to protect against concurrent access problems and to communicate between threads. Define the interaction between threads and between threads and object locks when executing sychronized, wait, notify, or notifyAll.
Java is a multithreaded programming language and a multithreaded execution environment. Because of this, competence with threads is even required from programmers who do not think the code they write will be threaded. Both the AWT and the Swing windowing toolkit execute in a multithreaded fashion because of the thread scheduling model. Therefore, even pure GUI programmers must be able to handle threads effectively.

Write code to define, instantiate, and start new threads using both java.lang.Thread and java.lang.Runnable.

This objective is intended to ensure that you have a clear grasp of the fundamentals of Java's threading capabilities. Using Thread or Runnable to create and launch threads is the basic mechanism by which all explicit threading in a Java program is started.

Critical Information

All threads start their execution in a run() method. The interface java.lang.Runnable a declares this method. The run() method can be implemented either in a class written for the purpose or in a subclass of java.1ang.Thread that overrides the implementation of the run() method provided in the Thread class.

The run() method's full signature is as follows:

public void run()

It cannot throw any checked exceptions because none are declared in the interface, and like all interface methods, it must be public.

New threads of execution are created when new Thread objects are created. If the code to be executed is provided by a separate class that implements Runnable, then an instance of the Runnable implementation should be passed into the Thread constructor. The new thread starts executing after the start() method of the Thread instance has been called. This is the case regardless of which class provided the run() method that the thread will execute.

The run() method is, first and foremost, just a method. It can be called directly, in which case it executes like any other method, in the calling thread. Every invocation of the run() method creates a unique set of local variables that have the lifetime of the method.

Exam Essentials

Know how to write and run code for a thread by implementing the interface java.lang.Runnable. Create a class that implements the interface Runnable. The run() method of this class may be used as the start point for a new thread if a Thread object is constructed with the Runnabl a implementation as an argument to the constructor. To launch the new thread, the start() method of the Thread object should be called.

Know how to write and run code for a thread by extending the class java.lang.Thread. Create a class that extends the Thread class. Create a run() method with the signature defined in the Runnable interface. Create an instance of the new Thread subclass and call the start() method to launch the new thread.

Know the significance and full prototype of the public void run() method declared in the interface java.lang.Runnable. Learn the prototype "public void run()" by heart. Know that this is the only way to provide the body of a thread-even Thread does this. Recognize that run() is a method like any other and, if called directly, will execute like any otherwithout creating any new thread. Recognize that every invocation of run(), like any other method, has its own set of local variables.

Know the distinction between the start() method of the Thread class and the run() method of the Runnable interface. Recognize that run() is where the thread starts execution, and distinguish this from start(), which is the method that creates and launches the new thread.

Key Terms and Concepts

java.lang.Runnable The interface that defines the run() method.

java.lang.Thread The class that provides the new thread of execution. Thread implements Runnable.

public void run() The method declared by the Runnable interface. This method is the starting point for a new thread's execution.

public void start() The method in the Thread class that launches a new thread's execution.

Sample Questions

1. Which classes are suitable for creating a new thread of execution, so that the class shown provides the code the thread executes?

A.

public class X implements Runnable { 
  public void 
run() {
    // code for the thread body goes here...
  }
}

B.

public class X implements Thread { 
  public void 
run() {
     // code for the thread body goes here...
  }
}         

C.

public class X extends Thread { 
  public int 
run() {
        // code for the thread body goes here...
  }
}

D.

public class X implements Runnable { 
  protected void 
run() {
    // code for the thread body goes here...
  }
}

E.

public class X extends Thread { 
  public void 
run() {
    // code for the thread body goes here...
  }
}

F.

public class X { 
  public void 
run() {
    // code for the thread body goes here...
  }
}

Answer: A, E. A is a conventional Runnable declaration. B does not compile, since Thread is a class and should therefore be extended, not implemented. The code of C would compile, but since the public void run() method that implements the Runnable interface has not been overridden, the body of the public int run() method does not provide the code for the thread. D is illegal, since all interface methods, including the run() method of Runnable, must be public. E is a conventional extension of Thread. F does not implement the Runnable interface, although it provides the method that is declared by Runnable. The implementation must be explicit....

Read More Show Less

Table of Contents

Introduction.

Chapter 1: Declarations and Access Control.

Chapter 2: Flow Control and Exception Handling.

Chapter 3: Garbage Collection.

Chapter 4: Language Fundamentals.

Chapter 5: Operators and Assignments.

Chapter 6: Overloading, Overriding, Runtime Type, and Object Orientation.

Chapter 7: Threads133Chapter8The java.awt Package.

Chapter 8: The java.awt Package

Chapter 9: The java.lang Package.

Chapter 10: The java.util Package.

Chapter 11: The java.io Package.

Appendix A: The Certification Initiative for Enterprise Development.

Glossary.

Index.

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)