Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Eccouncil Exam 312-96 Topic 9 Question 31 Discussion

Actual exam question for Eccouncil's 312-96 exam
Question #: 31
Topic #: 9
[All 312-96 Questions]

Which of the following method will you use in place of ex.printStackTrace() method to avoid printing stack trace on error?

Show Suggested Answer Hide Answer
Suggested Answer: C

Contribute your Thoughts:

Belen
3 months ago
C) ex.getMessage(); all the way. Unless of course, the error message is just 'Oops, my bad' - then the stack trace might be more helpful.
upvoted 0 times
Hui
2 months ago
True, it depends on the situation.
upvoted 0 times
...
Malcolm
2 months ago
But sometimes the stack trace can be useful for debugging.
upvoted 0 times
...
Lelia
2 months ago
Same here, it's cleaner and easier to read.
upvoted 0 times
...
Georgiann
2 months ago
I always use ex.getMessage() to avoid printing the stack trace.
upvoted 0 times
...
...
Janna
3 months ago
A) ex.StackTrace.getError(); wait, that's not even a real method! What kind of exam question is this?
upvoted 0 times
...
Mitzie
3 months ago
D) ex.getError(); is the way to go! Stack traces are for noobs, real developers know how to keep things concise.
upvoted 0 times
Clarinda
2 months ago
D) ex.getError(); is indeed the correct method to use, it keeps things clean and simple.
upvoted 0 times
...
Page
2 months ago
A) ex.StackTrace.getError(); is not a valid method either, so it's not the right choice.
upvoted 0 times
...
Caprice
2 months ago
B) ex.message(); is not a valid method, so it won't work in this case.
upvoted 0 times
...
Wayne
2 months ago
C) ex.getMessage(); is also a good option, it returns the error message without the stack trace.
upvoted 0 times
...
...
Curtis
3 months ago
B) ex.message(); sounds like it would do the trick. Though I wonder if it's a typo and should be ex.getMessage().
upvoted 0 times
Jamey
3 months ago
Yes, ex.getMessage() is the correct method to avoid printing stack trace.
upvoted 0 times
...
Eleonore
3 months ago
ex.message() is not a valid method, it should be ex.getMessage().
upvoted 0 times
...
Eladia
3 months ago
I think ex.message() should work fine.
upvoted 0 times
...
...
Janessa
4 months ago
I agree with Lorrine, using ex.getMessage() will avoid printing the stack trace
upvoted 0 times
...
Lorrine
4 months ago
I think the answer is C) ex.getMessage()
upvoted 0 times
...
Kirk
4 months ago
C) ex.getMessage(); seems like the obvious choice to me. Who needs a stack trace when you can just get the error message?
upvoted 0 times
Ashley
3 months ago
ex.getMessage() is much more concise and easier to read than ex.printStackTrace().
upvoted 0 times
...
Carisa
3 months ago
I always use ex.getMessage() to get the error message directly.
upvoted 0 times
...
Detra
3 months ago
ex.getMessage() is definitely cleaner than printing the whole stack trace.
upvoted 0 times
...
Ivan
3 months ago
I agree, ex.getMessage() is the way to go.
upvoted 0 times
...
...

Save Cancel