This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What assumption to make on assertion questions? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What assumption to make on assertion questions?" Watch "What assumption to make on assertion questions?" New topic

What assumption to make on assertion questions?

Rajeev Trikha
Ranch Hand

Joined: Jan 29, 2010
Posts: 85
When a question uses assert statements and the question says: 'What is the result? what should we assume regarding the fact whether assertions are enabled or not?

My concern is that by default the assertions are not enabled so even if the code says 'assert false' nothing will happen. The correct answer depends on the underlying assumption so just want to clarify.

Rajeev Trikha (SCJP 6)
Ankit Garg

Joined: Aug 03, 2008
Posts: 9327

Generally questions which involve assert statements are framed like this

"Given the following code


and the command used to run the program

java -ea MyClass

What will be the result"

So you don't have to make any assumptions. If the command is not given, you might find something in the question which says -> "assertions are enabled at runtime, what will be the result". If none of the two is given, then you can assume that assertions are not enabled at runtime...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
I agree. Here's the link:
subject: What assumption to make on assertion questions?