| 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
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
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
|
 |
 |
|
|
subject: What assumption to make on assertion questions?
|
|
|