Copyright

Java: Add Two Numbers Taking Input from User

Instructions:

Choose an answer and hit 'next'. You will receive your score and answers at the end.

question 1 of 3

This code will not compile, Java displays an error. What is missing?

Create Your Account To Take This Quiz

As a member, you'll also get unlimited access to over 79,000 lessons in math, English, science, history, and more. Plus, get practice tests, quizzes, and personalized coaching to help you succeed.

Try it risk-free
Try it risk-free for 30 days. Cancel anytime
Already registered? Log in here for access

1. Examine the following code. What is true about the variable inputValue?

2. Examine the following code. What could we add to ensure only integers were entered?

Create your account to access this entire worksheet
A Premium account gives you access to all lesson, practice exams, quizzes & worksheets
Access to all video lessons
Quizzes, practice exams & worksheets
Certificate of Completion
Access to instructors
Create an account to get started Create Account

About This Quiz and Worksheet

Adding two numbers in the Java language is the subject of this quiz and worksheet. On the quiz, you'll tackle questions on what is missing in a given error message, as well as data types that could be entered without an error in an example.

Quiz and Worksheet Goals

The subjects mentioned below can be found in the questions of the quiz:

  • Code using inputValue
  • Adding code to ensure only integers are included
  • Which data type to use for conversion
  • Data types to use so that errors do not happen in a given code example

Skills Practiced

  • Information recall - remember what you have learned about error generation in Java
  • Knowledge application - use what you know to answer questions about ensuring that only integers are entered
  • Interpreting information - make sure you can read information about which data type to use to convert input and interpret it correctly

Additional Learning

For more help, open the lesson titled Java: Add Two Numbers Taking Input from User. With this, you can delve into the additional material listed here:

  • The Scanner utility
  • Running a program
  • Checking the output
  • Code examples to follow along with
Support