
1.1.5 Intro to programming quiz review
Quiz
•
Computers
•
9th - 12th Grade
•
Hard
Michael Courtright
Used 4+ times
FREE Resource
Enhance your content in a minute
8 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following code segment in the image
1
0.0
1.0
8.0
0.0
Answer explanation
In the following statements, the values of variables a, b, and c are plugged into this expression: a b / c a / b c
int a = 5;
int b = 4;
int c = 2;
double x = a b / c a / b c;
The expression is evaluated using the precedence of operators, as follows:
a b / c a / b c
= 5 4 / 2 5 / 4 2 // 5 / 4 is 1, as it is integer division.
= 20 / 2 1 * 2 // 20 / 2 is 10, as
it is integer division.
= 10 2
= 8
8 is assigned to double type variable x, therefore the output is 8.0.
2.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Answer the question in the image
10 11 45 25
10 11 46 25
10 11 47 26
10 10 46 25
10 10 40 20
Answer explanation
The execution of the statements is as follows:
int score = 10; // The value of 10 is assigned to the variable score.
System.out.print(score + " ");
// The value of score, 10, is displayed and followed by a space.
System.out.print(score++ + " ");
/* The value of score, 10, is then incremented to 11. */
score *= 2;
// The value of score, 11, is doubled, making it 22.
System.out.print(++score*2 + " ");
/* The value of score is incremented to 23 first, so 46 is displayed.
*/ int penalty = 4;
// The value of 4 is assigned to penalty. score += penalty/2;
// The result of 4/2 = 2 is added to score, making it 25.
System.out.print(score + " ");
// 25 is displayed.
So, the complete output is 10 10 46 25.
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
How many bytes are occupied by a variable of the int data type in the Java programming language?
1
2
4
8
16
Answer explanation
An int data type variable in Java occupies 4 bytes of memory.
4.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
final float PI = 3.14;
System.out.println("The volume of a cylinder is: " + (PI*radius*radius*height) );
int PI = 3.14;
System.out.println("The volume of a cylinder is: "+ (PI*radius*radius*height) );
final double pi = 3.14;
System.out.println("The volume of a cylinder is: "+ (PI*radius*radius*height) );
final double PI = 3.14;
System.out.println("The volume of a cylinder is: "+ (PI*radius*radius*height) );
final double PI;
System.out.println("The volume of a cylinder is: "+ (PI*radius*radius*height) );
Answer explanation
The value of pi is constant, so the desired output requires the usage of the final keyword for declaring a named constant.
Choice D declares a named constant PI with the appropriate data type and uses it to display the output as required.
Choice A is not correct, as the declaration statement is assigning a double value to a float type constant, which will generate a syntax error. Recall that floating type literals are of the double data type by default in Java.
Choice B does not declare a named constant.
Choice C will generate a syntax error, as the declaration statement declares the named constant as pi and uses PI in System.out.println().
Choice E will generate a syntax error, as the declaration statement does not assign a constant value.
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which of the following statements is true?
Integer variables cannot be used as an operand for the / operator.
The data type of a variable is used to determine where the variable is stored in computer memory when the program is executed.
In Java, the data types in the declaration statements of named constants are needed only for documentation purposes.
The data type of a variable determines the kind of operations that can be performed on the variable.
Variables of the float data type are represented in memory as strings of decimal digits with a decimal point and an optional sign.
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Answer the question in the image.
Happy New YearWelcome 2022
Happy New Year Welcome2022
HappyNewYearWelcome2022
Welcome 2022 Happy New Year
Happy New Year Welcome 2022
7.
MULTIPLE CHOICE QUESTION
1 min • 5 pts
Which of the following data types is the correct option for creating a variable that can be assigned the numeric value 345.67?
double
boolean
int
byte
char
8.
FILL IN THE BLANK QUESTION
3 mins • 3 pts
What will be the final answer to the following arithmetic expression if it is evaluated using rules of operator precedence and associativity?
y += u + v * w/x – z
where u = 5, v = 3, w= 4, x= 6, z = 2.
Assume all variables are of integer data type.
Answer explanation
y += u + v * w/x – z
where u = 5, v = 3, w= 4, x= 6, z = 2.
y += 5 + (3 * 4)/6 - 2
y += 5 + (12/6) -2
y += (5 + 2) - 2
y += (7 - 2)
y += 5
*Can't go any further, since we don't know the value of y
Similar Resources on Wayground
10 questions
Network
Quiz
•
10th - 11th Grade
10 questions
ICT 9 Quiz 1
Quiz
•
9th Grade
10 questions
ZOOM QUIZ
Quiz
•
1st - 12th Grade
10 questions
1.8 Open Source & Closed Source TRUE or FALSE
Quiz
•
10th Grade
10 questions
hardware and software(g3)
Quiz
•
2nd - 10th Grade
10 questions
EMPTECH L4 Q3
Quiz
•
12th Grade
10 questions
Microcontroller
Quiz
•
11th Grade - University
13 questions
9G4 CS Python Programming Sequence and Vocabs
Quiz
•
9th Grade
Popular Resources on Wayground
5 questions
This is not a...winter edition (Drawing game)
Quiz
•
1st - 5th Grade
15 questions
4:3 Model Multiplication of Decimals by Whole Numbers
Quiz
•
5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
10 questions
The Best Christmas Pageant Ever Chapters 1 & 2
Quiz
•
4th Grade
12 questions
Unit 4 Review Day
Quiz
•
3rd Grade
10 questions
Identify Iconic Christmas Movie Scenes
Interactive video
•
6th - 10th Grade
20 questions
Christmas Trivia
Quiz
•
6th - 8th Grade
18 questions
Kids Christmas Trivia
Quiz
•
KG - 5th Grade
Discover more resources for Computers
15 questions
Internet Vocabulary Notebook Check #2 - CTEA(2024)
Quiz
•
12th Grade
11 questions
Internet Terms Vocabulary- Notebook Check #1- CTEA
Quiz
•
12th Grade
39 questions
UNIT 7 and UNIT 8 — Multiple Choice Question Bank (Extracted)
Quiz
•
9th Grade
50 questions
Money Matters Fall 2025 Final Exam — Worksheet Questions
Quiz
•
12th Grade
47 questions
CSF Final Exam Practice
Quiz
•
9th - 12th Grade
