aspose file tools*
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
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
Author

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
Sheriff

Joined: Aug 03, 2008
Posts: 9302
    
  17

Generally questions which involve assert statements are framed like this

"Given the following code

/*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
 
jQuery in Action, 2nd edition
 
subject: What assumption to make on assertion questions?