Skip Top Navigation Bar

Declaring and Initializing Variables Practice

Your Turn: Declare and Initialize Variables Based on Descriptions

For the data descriptions

  • Determine whether they are primitive data or object data.
  • If they are primitive data, which of the 4 data types would be best to use to represent the data? The 4 primitive data types we will use are: int, double, char, boolean.
  • If it is primitive data, what would the initial value might be?
  • If it is primitive data, write your statements in the Java playground.

Your Turn: Making Modifications to Variable Declarations

  • For each of the following variable declarations, make modification so that the code works as intended.

Practice 1

  • Declare and initialize a variable to store whether a person is considered an adult or not.

Practice 2

  • Declare and initialize a variable to store the average weight of an apple.

Practice 3

  • Declare and initialize a variable to store a letter grade.

Practice 4

  • Declare and initialize a variable to the capacity of a bus.