Limited access

Upgrade to access all content for this subject

Of the following situations, which would be the best example of when you should consider throwing an IllegalArgumentException within your code?


Your method accepts an object as its parameter and the object has not been instantiated.


Your method accepts an integer parameter that needs to be within a specific range and the parameter is outside of that range.


The parameters required by the class’ constructor method do not match the parameters when instantiating the object from another class.


Your method requires a String as its parameter and it is passed an integer.


Your method is supposed to return a positive integer, but it is returning a negative number.

Select an assignment template