1.1.2 Variables worksheet

1.1.2 Variables worksheet

12th Grade

11 Qs

quiz-placeholder

Similar activities

[Hall] Unit 8 JS Variables & Animation

[Hall] Unit 8 JS Variables & Animation

9th - 12th Grade

13 Qs

E-quiz

E-quiz

12th Grade

10 Qs

More JavaScript Basics

More JavaScript Basics

9th - 12th Grade

15 Qs

Unit 1 Review AP CSP

Unit 1 Review AP CSP

9th - 12th Grade

10 Qs

Ch_9 Introduction to ActionScript

Ch_9 Introduction to ActionScript

9th - 12th Grade

15 Qs

CodeHS Concepts of Programming JavaScript

CodeHS Concepts of Programming JavaScript

9th - 12th Grade

15 Qs

Javascript Starter

Javascript Starter

12th Grade

14 Qs

Repaso Teórico Conceptos Pascal

Repaso Teórico Conceptos Pascal

8th - 12th Grade

14 Qs

1.1.2 Variables worksheet

1.1.2 Variables worksheet

Assessment

Quiz

Computers

12th Grade

Easy

Created by

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

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?