1.2.2 Variables and Types

0.0(0)
Studied by 23 people
0%Unit 1 Mastery
0%Exam Mastery
Build your Mastery score
multiple choiceMultiple Choice
call kaiCall Kai
Supplemental Materials
Card Sorting

1/5

Last updated 11:05 PM on 3/21/25
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

6 Terms

1
New cards

Which of the following is a proper way to declare and initialize an int variable in Java?

int myNumber = 10;

2
New cards

Consider the following code snippet.

public static void main(String args[]){
    final int z;
    z = 20;
    z = 30;
    System.out.println(z);
}

What value of z is actually printed?

This code gives an error.

3
New cards

What are the memory values associated with the variables x, y, and z after the code snippet below executes?

int x = 7;            
double y = 2.0;             
boolean z = false;

x = x + 3;             
z = true;

x holds the int value 10, y holds the double value 2.0 and z holds the boolean value true.

4
New cards

Which of the following variable names follows best practices for naming a variable?

5apples

someVariable

applesnum

numApples

numApples

5
New cards

What does the keyword final do?

It prevents variables from being altered.

6
New cards

What will be the output of the following code snippet:

public class Variables 
{
    public static void main(String[] args)
    {
        int totalBirds = 150;
        double averageTime = 45.7;
        String mostCommon = "Mallard Duck";

        System.out.println("Bird Watching Results");
        System.out.print("Total birds seen: ");
        System.out.println(totalBirds);

        System.out.print("Average time between sightings: ");
        System.out.println(averageTime);

        System.out.print("Most common bird seen was ");
        System.out.println(mostCommon);
    }
}

Bird Watching Results
Total birds seen: 150
Average time between sightings: 45.7
Most common bird seen was Mallard Duck

Explore top notes

note
Gases and Solutions
Updated 1206d ago
0.0(0)
note
Chapter 3: Federalism
Updated 1019d ago
0.0(0)
note
apush 5.1-5.3
Updated 464d ago
0.0(0)
note
Español 3H Repaso vocabulario
Updated 1060d ago
0.0(0)
note
Cranial Nerves
Updated 392d ago
0.0(0)
note
Gases and Solutions
Updated 1206d ago
0.0(0)
note
Chapter 3: Federalism
Updated 1019d ago
0.0(0)
note
apush 5.1-5.3
Updated 464d ago
0.0(0)
note
Español 3H Repaso vocabulario
Updated 1060d ago
0.0(0)
note
Cranial Nerves
Updated 392d ago
0.0(0)

Explore top flashcards

flashcards
Bio Lecture Final
276
Updated 690d ago
0.0(0)
flashcards
Microbiology Exam 4 Part 2
108
Updated 1062d ago
0.0(0)
flashcards
industrialization study guide
20
Updated 913d ago
0.0(0)
flashcards
Mesopotamia vocab
37
Updated 123d ago
0.0(0)
flashcards
bio practical 3
82
Updated 1077d ago
0.0(0)
flashcards
AD 227 Exam 3 Key Works
33
Updated 315d ago
0.0(0)
flashcards
Bio Lecture Final
276
Updated 690d ago
0.0(0)
flashcards
Microbiology Exam 4 Part 2
108
Updated 1062d ago
0.0(0)
flashcards
industrialization study guide
20
Updated 913d ago
0.0(0)
flashcards
Mesopotamia vocab
37
Updated 123d ago
0.0(0)
flashcards
bio practical 3
82
Updated 1077d ago
0.0(0)
flashcards
AD 227 Exam 3 Key Works
33
Updated 315d ago
0.0(0)