
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
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
Les variables sous Python
Quiz
•
10th - 12th Grade
10 questions
Parcial-Dibujo
Quiz
•
12th Grade
10 questions
Empowerment Technologies Quiz 2
Quiz
•
11th Grade
10 questions
Unit 4 Advanced AP CSP
Quiz
•
9th - 12th Grade
12 questions
Spreadsheet Starter
Quiz
•
7th Grade - University
10 questions
Cyber Security
Quiz
•
1st - 10th Grade
12 questions
Examen final algoritmo
Quiz
•
11th Grade
10 questions
Inspire - AI Trivia
Quiz
•
11th Grade
Popular Resources on Wayground
8 questions
2 Step Word Problems
Quiz
•
KG - University
20 questions
Comparing Fractions
Quiz
•
4th Grade
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
10 questions
Latin Bases claus(clois,clos, clud, clus) and ped
Quiz
•
6th - 8th Grade
22 questions
fractions
Quiz
•
3rd Grade
7 questions
The Story of Books
Quiz
•
6th - 8th Grade
