WorksheetsQuiz 03 - Variables
Total questions: 10
Worksheet time: 50mins
Which of the following is the correct way to declare a variable called "hours" to store the integer 8?
hours = 8;
hour = int(8);
int hours = 8;
int hours = 8
What does the following instruction do?
unitPrice = 7.99;
change the value of unitPrice to 7.99
create a memory box to hold 7.99
set the inital value of unitPrice to 7.99
check if the value of unitPrice equals 7.99
Which of the following is an appropriate variable name?
lastname
lastName
LastName
LAST_NAME
Which of the following is a correct way to print text containing a variable's value?
System.out.println("Hello " + name + "!");
System.out.println("Hello " & name & "!");
System.out.println("Hello " name "!");
System.out.println("Hello ", name, "!");
Which of the following is an appropriate name for a constant?
gravitationalConstant
GRAVITATIONALCONSTANT
GravitationalConstant
GRAVITATIONAL_CONSTANT
Which variable type should be used to store the number of items in stock at a grocery store?
int
long
double
String
Which variable type should be used to store the name of an item in a grocery store?
int
long
double
String
Which variable type should be used to store 13-digit serial number of an item in a grocery store?
int
long
double
String
Which variable type should be used to store the price of an item in a grocery store?
int
long
double
String
Which statement will define a constant?
static int HOURS_PER_DAY = 24;
final int HOURS_PER_DAY = 24;
int HOURS_PER_DAY = 24;
constant int HOURS_PER_DAY = 24;
