Question: X1155: Throwing an Exception The method below takes in a String parameter representing a username. It should throw an Exception if the username is less

X1155: Throwing an Exception

The method below takes in a String parameter representing a username. It should throw an Exception if the username is less than 3 characters long. The method correctly throws the exception, but something is still missing. Fix the problem.

public String validateUser(String userName) { if (userName.length() < 3) { throw new Exception("userName is too short"); } return userName; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!