
1.1.2 Variables worksheet

Quiz
•
Computers
•
12th Grade
•
Easy
Terri Koehler
Used 2+ times
FREE Resource
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'.
Create a free account and access millions of resources
Similar Resources on Wayground
12 questions
C++ References

Quiz
•
6th - 12th Grade
15 questions
Python Basics Quiz

Quiz
•
9th - 12th Grade
10 questions
JavaScript-01

Quiz
•
12th Grade
15 questions
Просвещения Web-программирование №10 Тест 2024

Quiz
•
9th - 12th Grade
15 questions
JavaScript and Graphics

Quiz
•
9th - 12th Grade
16 questions
Python basics

Quiz
•
9th - 12th Grade
10 questions
10 Important Python Fundamentals Questions

Quiz
•
12th Grade
12 questions
Define Variables

Quiz
•
9th - 12th Grade
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade