
1.1.2 Variables worksheet
Quiz
•
Computers
•
12th Grade
•
Practice Problem
•
Easy
Terri Koehler
Used 2+ times
FREE Resource
Enhance your content in a minute
11 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which statement would you add to display the two other variables that have been declared and initialized?
print(variable1, variable2)
display(variable1, variable2)
show(variable1, variable2)
log(variable1, variable2)
Answer explanation
The correct choice is 'print(variable1, variable2)' because 'print' is a standard function in many programming languages to output values to the console. The other options do not represent standard output functions.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is a primitive data type that stores whole numbers?
A) int
B) boolean
C) double
Answer explanation
The correct choice is A) int, which is a primitive data type used to store whole numbers. Options B) boolean and C) double represent different data types: boolean for true/false values and double for floating-point numbers.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Fill in the blank: A _______ variable is stored in a specific memory location and only stores decimal values.
double
integer
character
boolean
Answer explanation
A double variable is specifically designed to store decimal values and is allocated a specific memory location for this purpose. In contrast, integer, character, and boolean types do not store decimal values.
4.
OPEN ENDED QUESTION
3 mins • 1 pt
What is the naming convention used in Java for methods and variables when using two words in a variable name?
Evaluate responses using AI:
OFF
Answer explanation
In Java, the naming convention for methods and variables using two words is camelCase. The first word is in lowercase, and the subsequent words start with an uppercase letter, e.g., 'myVariable' or 'calculateTotal'.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following are rules for naming variables in Java?
Variable names must start with a letter, underscore, or dollar sign.
Variable names can contain spaces.
Variable names are case-sensitive.
Variable names can start with a number.
Answer explanation
In Java, variable names must start with a letter, underscore, or dollar sign. They cannot contain spaces, are case-sensitive, and cannot start with a number. Thus, the correct rule is that variable names must start with a letter, underscore, or dollar sign.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of declaring a variable as 'final' in programming?
To allow the variable to be modified later
To prevent the variable from being modified
To make the variable accessible globally
To enhance the performance of the program
Answer explanation
Declaring a variable as 'final' prevents it from being modified after its initial assignment. This ensures that the value remains constant throughout its scope, which can help avoid unintended changes and improve code reliability.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is an example of a 'final' variable?
int age = 12;
final double ALLOWANCE = 8.75;
age = 13;
int speed = 60;
Answer explanation
The correct choice is 'final double ALLOWANCE = 8.75;' because 'final' indicates that the variable's value cannot be changed after it is initialized, making it a constant. The other options do not use 'final'.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
Les variables sous Python
Quiz
•
10th - 12th Grade
10 questions
AP Computer Science Principles - Unit 7: Parameters, Returns
Quiz
•
9th - 12th Grade
10 questions
Parcial-Dibujo
Quiz
•
12th Grade
10 questions
Mobile Genap
Quiz
•
12th Grade
16 questions
Python programming
Quiz
•
6th - 12th Grade
10 questions
Python- Operators
Quiz
•
12th Grade
10 questions
Python Alternating Turns
Quiz
•
7th - 12th Grade
14 questions
Linux: Users and Groups
Quiz
•
9th Grade - University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
54 questions
Analyzing Line Graphs & Tables
Quiz
•
4th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
