go to previous page   go to home page   go to next page        

Answer:

if ( args.length != 3 || !args[1].toUpperCase().equals("TO") )
{
  System.out.println("java CopyBytes source to destination");
  return;
}

Avoid ArrayIndexOutOfBoundsException

The above is the only correct answer, given the choices. The args.length != 3 must come first. If it is true, then the short-circuit OR immediately evaluates to true and there is no danger of trying to look at a non-existent args[1].

If the order were reversed (or if a non-short-circuit OR where used), then the if might throw an ArrayIndexOutOfBoundsException.

QUESTION 21:

Does this code protect the user against accidentally reversing the order of the source and the destination file?