Skip Top Navigation Bar

Declaring and Initializing Variables Practice

Declare and Initialize Variables Based on Descriptions

For the data descriptions listed below, first determine whether they are primitive data or object data. If they are primitive data, which of the 8 data types would be best to use to represent the data? The 8 primitive data types are: byte, short, int, long, float, double, char, boolean. If it is primitive data, what would the initial value might be? Try your statements in the Java playground. Be sure to toggle the console to Detailed Output to see what is happening in the program.

  1. A student's age
  2. The grade a student is in
  3. Student's GPA
  4. A Game Score
  5. Whether you want to continue the game or not
  6. A middle initial
  7. The color of a block
  8. Whether someone is married or not
  9. Price of a menu item
  10. The number of degrees to rotate a robot to the right
  11. The date for the first day of school
  12. The number of minutes until your order is ready
  13. The name of the school
  14. Price per unit for fruit
  15. Your street address
  16. A customer's phone number
  17. A meteorite landing that includes the name of the meteorite, the date it landed, its mass, and landing location
  18. A spinner that has 4 equal sections each with a different color
  19. A card in a deck of 52 cards
  20. The response from an invited guest for whether they are attending a party or not

Making Modifications to Variable Declarations

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

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

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

Declare and initialize a variable to store a letter grade.

Declare and initialize a variable to the capacity of a buss.