CIS 35A: Introduction to Java Programming

Home | Green Sheet | Lectures | Assignments | FAQ

Validate

Validate input data
Objectives

Applied

  • Given an application that uses the console to get input from the user, write code that handles any exceptions that might occur.
  • Given an application that uses the console to get input from the user and the validation specifications for that data, write code that validates the user entries.
  • Given the Java code for an application that uses any of the language elements presented in this chapter, explain what each statement in the application does.

Knowledge

  • Explain what an exception is in Java.
  • Describe the Exception hierarchy and name two of its subclasses.
  • Explain what the stack trace is and how you can use it to determine the cause of an exception.
  • Explain how you use the try statement to catch an exception.
  • Explain what an exception handler is and when the code in an exception handler is executed.
  • Explain how you can use methods of the Scanner class to validate data.
  • Explain why it's usually better to validate user entries than to catch and handle exceptions caused by invalid entries.
  • Describe the two types of data validation that you're most likely to perform on a user entry.
  • Explain why you might want to use generic methods for data validation.
Handle exceptions | Validate data | Application