public class TestClass
{
public static void main(String[] args)
{
assert args.length == 2 : "Must give two arguments";
...
}
}
right answer "The programmer should throw a RuntimeException instead of using an assertion in this case"
I choosed "This is an appropriate use of assertions."
Weird... the book state
Don't Use Assertions to Validate Command-Line Arguments
Don't Use Assertions to Validate Arguments to a Public Method
About Question com.enthuware.ets.scjp.v6.2.222 :
Moderator: admin
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.222 :
Here, the code is using assertion to validate argument to a method, which is not advisable. Therefore, the given answer is correct.
HTH,
Paul.
HTH,
Paul.
Who is online
Users browsing this forum: Bing [Bot] and 8 guests