File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Explain me printStackTrace?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Explain me printStackTrace??" Watch "Explain me printStackTrace??" New topic
Author

Explain me printStackTrace??

josephine chen
Ranch Hand

Joined: Oct 29, 2002
Posts: 216

//It is printing numbers but what does it exactly do???
[ Jess fixed the [code] block ]
[ March 26, 2003: Message edited by: Jessica Sant ]
Lucy C
Ranch Hand

Joined: Feb 09, 2000
Posts: 53
The printStackTrace method is a method of the Throwable class - the superclass of all Exceptions. Basically, it just prints out where the Exception in question occurred by giving you the list of method calls that resulted in the Exception being thrown. It's very useful for debugging!
Incidentally, it's got nothing to do with the numbers your code is printing out - they're from the running thread's run method, which is just incrementing i and printing the result...
Karin Paola Illuminate
Ranch Hand

Joined: Oct 18, 2002
Posts: 109

Do I need to know what the methods fillInStackTrace() and printStackTrace() do for the exam?
Do I also need to know how to throw an object of type Throwable for the exam?
[ March 26, 2003: Message edited by: Karin Paola Illuminate ]

I not only use all the brains that I have, but all that I can borrow. [Laurence J. Peter]
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

the exam objectives state:
  • Write code that makes proper use of exceptions and exception handling clauses (try, catch, finally) and declares methods and overriding methods that throw exceptions.
  • Recognize the effect of an exception arising at a specified point in a code fragment. Note: The exception may be a runtime exception, a checked exception, or an error (the code may include try, catch, or finally clauses in any legitimate combination).


  • So... you definitely need to know how to use a try /catch block -- and the finally clause too. You should understand the difference between checked / unchecked exceptions -- (and the basic Exception class hierarchy too).
    However (according to the Sierra/Bates book) For th exam, it is not necessary to know any of the methods contained in the class Throwable... You are expected to know tha Exeption, Error, RuntimeException, and Throwable types can all be thrown using the throws keyword, and can all be caught (although you rarely will catch anything other than Exception subtypes).


    - Jess
    Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
    Karin Paola Illuminate
    Ranch Hand

    Joined: Oct 18, 2002
    Posts: 109
    Jessica. Thanks.
     
    GeeCON Prague 2014
     
    subject: Explain me printStackTrace??