Variables and Data Types MCQ Practice

Question 1 of 10

An orchid conservatory program tracks how many display benches currently hold plants. The value is a whole number from 0 through 36. Which type best matches this specification?

  1. A. boolean
  2. B. double
  3. C. int
  4. D. A reference type for an entire plant record

Question 2 of 10

Overnight glasshouse air is recorded as values such as 18.6 degrees. Which type is appropriate for this reading?

  1. A. double
  2. B. int, because every temperature must be a whole number
  3. C. boolean
  4. D. A reference type, because any sensor reading is automatically an object

Question 3 of 10

Staff must store only whether the automatic ridge vent is currently open. Which type models that requirement directly?

  1. A. int, encoding the two states as 1 and 0
  2. B. double
  3. C. A reference type named VentLog
  4. D. boolean

Question 4 of 10

The software represents an OrchidSpecimen that combines cultivar name, pot diameter, and bloom notes in one object. Which category describes the OrchidSpecimen type?

  1. A. Primitive numeric
  2. B. Reference
  3. C. Primitive Boolean
  4. D. Primitive, because pot diameter might be stored as int

Question 5 of 10

A conservatory method uses a primitive variable benchCount and a reference variable named sensor that refers to a Sensor object. Which statement is accurate?

  1. A. benchCount stores an actual integer value; sensor stores a reference to a Sensor object.
  2. B. Both variables store Sensor objects.
  3. C. sensor packs every Sensor field into a single int.
  4. D. Primitive variables store memory addresses, and reference variables store true or false.

Question 6 of 10

Which Java declaration introduces an integer variable named mistCycles?

  1. A. integer mistCycles;
  2. B. int mistCycles;
  3. C. mistCycles int;
  4. D. boolean mistCycles;

Question 7 of 10

Consider this declaration. What are the variable name and the data type?

double canopySpread;
  1. A. Name double; type canopySpread
  2. B. Name canopySpread; type boolean
  3. C. Name canopySpread; type double
  4. D. Name canopySpread; type int

Question 8 of 10

Using the table, which declaration is correct for shadeDrawn?

Name Need
traySlots Whole-number empty tray slots
sapPh Soil pH that may include a decimal
shadeDrawn Whether the shade cloth is down
  1. A. int shadeDrawn;
  2. B. double shadeDrawn;
  3. C. ShadeCloth shadeDrawn;
  4. D. boolean shadeDrawn;

Question 9 of 10

A student writes int heaterReady; because the identifier sounds like a yes-or-no flag. Why is heaterReady not a Boolean variable?

  1. A. The declared type is int, so the variable holds an integer value rather than true or false.
  2. B. Any identifier containing Ready is illegal in Java.
  3. C. int is a reference type.
  4. D. Boolean variables cannot be declared in this course.

Question 10 of 10

Which line declares a Boolean variable named foggerArmed and does not give the variable an initial value?

  1. A. FoggerArmed boolean;
  2. B. boolean armedFogger;
  3. C. boolean foggerArmed;
  4. D. int foggerArmed;