What is the value of the boolean variable canVote at the end of this program?
var age = 17;
var isCitizen = true;
var canVote = age >= 18 && isCitizen;
Javascript Control Structures Practice

Flashcard
•
Computers
•
9th - 12th Grade
•
Hard
Quizizz Content
FREE Resource
Student preview

14 questions
Show all answers
1.
FLASHCARD QUESTION
Front
Back
False
Answer explanation
The variable canVote is determined by the expression age >= 18 && isCitizen. Since age is 17 (not >= 18), the expression evaluates to false. Therefore, the value of canVote is False.
2.
FLASHCARD QUESTION
Front
What will be the output of this program?
var number = 5;
var greater_than_zero = number > 0;
if (greater_than_zero){
println(number);
}
Back
5
Answer explanation
The variable 'number' is set to 5. The condition 'greater_than_zero' evaluates to true since 5 > 0. Therefore, the program prints the value of 'number', which is 5.
3.
FLASHCARD QUESTION
Front
What will be the output of this program?
var number = 5;
var greater_than_zero = number > 0;
if (greater_than_zero){
if (number > 5){
println(number);
}
}
Back
Nothing will print
Answer explanation
The variable 'greater_than_zero' is true since 5 > 0. However, the inner condition 'number > 5' is false, so 'println(number)' does not execute. Therefore, nothing will print.
4.
FLASHCARD QUESTION
Front
What is printed by the following program?
var isRaining = false;
var isCloudy = false;
var isSunny = !isRaining && !isCloudy;
var isSummer = false;
var isWarm = isSunny || isSummer;
println("Is it warm: " + isWarm);
Back
Is it warm: true
Answer explanation
isSunny is true because both isRaining and isCloudy are false. isWarm is true since isSunny is true, regardless of isSummer. Therefore, the output is 'Is it warm: true'.
5.
FLASHCARD QUESTION
Front
What is printed by the following program?
var numApples = 10;
var numOranges = 5;
if(numApples < 20 || numOranges == numApples){
println("Hello, we are open!");
} else {
println("Sorry, we are closed!");
}
println("Sincerely, the grocery store");
Back
Hello, we are open!
Sincerely, the grocery store
Answer explanation
The condition 'numApples < 20' is true (10 < 20), so 'Hello, we are open!' is printed. The final line 'Sincerely, the grocery store' is also printed, making the correct choice: 'Hello, we are open!' and 'Sincerely, the grocery store'.
6.
FLASHCARD QUESTION
Front
What will the following program print when run?
var above16 = true;
var hasPermit = true;
var passedTest = false;
if (above16 && hasPermit && passedTest){
println("Issue Driver's License");
} else {
if (above16 || hasPermit || passedTest) {
println("Almost eligible for Driver's License");
} else {
println("No requirements met.");
}
}
Back
Almost eligible for Driver’s License
Answer explanation
The program checks if all conditions (above16, hasPermit, passedTest) are true. Since passedTest is false, it goes to the else block. One condition is true (above16), so it prints 'Almost eligible for Driver's License'.
7.
FLASHCARD QUESTION
Front
What will the following program print when run?
var numberOne = 5;
var numberTwo = 10;
if (numberOne == 5) {
println(1);
}
if (numberOne > 5) {
println(2);
}
if (numberTwo < 5) {
println(3);
}
if (numberOne < numberTwo) {
println(4);
}
if (numberOne != numberTwo) {
println(5);
}
Back
1
4
5
Answer explanation
The program prints 1 because numberOne is 5. It does not print 2 or 3 since those conditions are false. It prints 4 because numberOne (5) is less than numberTwo (10) and prints 5 because numberOne is not equal to numberTwo.
Create a free account and access millions of resources
Similar Resources on Quizizz
13 questions
java variables 1

Flashcard
•
9th - 12th Grade
12 questions
CS Python Fundamentals Unit 4 Review

Flashcard
•
9th - 12th Grade
13 questions
Functions and Parameters

Flashcard
•
9th - 12th Grade
10 questions
Paper Practice 2

Flashcard
•
9th - 12th Grade
8 questions
AP CS A Flashcard 4 Practice

Flashcard
•
9th - 12th Grade
16 questions
Loops Flashcard

Flashcard
•
9th - 12th Grade
12 questions
CSP-A114 Flashcard

Flashcard
•
9th - 12th Grade
8 questions
AP CSP 12-2 U4L1 Variable

Flashcard
•
9th - 12th Grade
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade
Discover more resources for Computers
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
20 questions
Taxes

Quiz
•
9th - 12th Grade
17 questions
Parts of Speech

Quiz
•
7th - 12th Grade
20 questions
Chapter 3 - Making a Good Impression

Quiz
•
9th - 12th Grade
20 questions
Inequalities Graphing

Quiz
•
9th - 12th Grade
10 questions
Identifying equations

Quiz
•
KG - University