
APDQ 2.1 - 2.3
Quiz
•
Computers
•
12th Grade
•
Practice Problem
•
Hard
enorberg@dupage88.net enorberg@dupage88.net
Used 1+ times
FREE Resource
Enhance your content in a minute
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code segment.
int temp = 75;
String choice;
boolean hasSibling = false;
if (temp < 70)
{
choice = "Indoors";
}
else
{
choice = "Outdoors";
}
if (hasSibling)
{
choice += " with sibling";
}
What is the value of choice after executing the code segment?
"Indoors"
"Outdoors"
"Indoors with sibling"
"Outdoors with sibling"
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code segment.
int x = 3;
int y = -1;
if (x - 2 > y)
{
x -= y;
}
if (y + 3 >= x)
{
y += x;
}
System.out.print("x = " + x + ", y = " + y);
What is printed as a result of executing the code segment?
x = 2, y = 1
x = 3, y = 2
x = 4, y = -1
x = 4, y = 3
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following two code segments where the int variable choice has been properly declared and initialized.
Code Segment 1
if (choice > 10)
{
System.out.println("blue");
}
else if (choice < 5)
{
System.out.println("red");
}
else
{
System.out.println("yellow");
}
Code Segment 2
if (choice > 10)
{
System.out.println("blue");
}
if (choice < 5)
{
System.out.println("red");
}
else
{
System.out.println("yellow");
}
Assume that both code segments initialize choice to the same integer value. Which of the following best describes the conditions on the initial value of the variable choice that will cause the two code segments to produce different output?
choice > 5 and choice < 10
choice > 10
choice == 5 or choice == 10
There is no value for choice that will cause the two code segments to produce different output.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following partial Person class definition. The instance variable adult should be set to true if the person’s age is at
least 18 years old, and should be set to false otherwise.
public class Person
{
private String name;
private int age;
private boolean adult;
public Person(String n, int a)
{
name = n;
age = a;
if (age >= 18)
{
adult = true;
}
else
{
adult = false;
}
}
// There are no other constructors.
// There may be other methods that are not shown.
}
Which of the following statements, when appearing in a method in a class other than Person, will correctly a
create an instance of a Person object that represents an adult person?
Person p = new Person("Homer", 23);
Person p = new Person("Homer", "23");
Person p = new Person("Homer", true);
Person p = new Person("Homer", 17);
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In the following code segment, the int variables a, b, c, and d have been properly declared and initialized.
if (a < b || c != d)
{
System.out.println("dog");
}
else
{
System.out.println("cat");
}
5. Which of the following code segments produces the same output as the given code segment for all values of a, b, c, and d?
if (a < b && c != d)
{
System.out.println("dog");
}
else
{
System.out.println("cat");
}
if (a > b && c == d)
{
System.out.println("cat");
}
else
{
System.out.println("dog");
}
if (a >= b || c == d)
{
System.out.println("cat");
}
else
{
System.out.println("dog");
}
if (a >= b && c == d)
{
System.out.println("cat");
}
else
{
System.out.println("dog");
}
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code segment.
int a = 10;
int b = 5 * 2;
System.out.print(a == b);
What is printed as a result of executing the code segment?
10
10 == 10
true
false
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code segment. double regularPrice = 100.0; boolean onClearance = true; boolean hasCoupon = false; double finalPrice = regularPrice; if (onClearance) { finalPrice -= finalPrice * 0.25; } if (hasCoupon) { finalPrice -= 5.0; } System.out.println(finalPrice); What is printed as a result of executing the code segment?
20.0
25.0
70.0
75.0
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
AP CSP Global Impact
Quiz
•
9th - 12th Grade
15 questions
Unit 1 LO5 Ethical and Operational Issues and Threats
Quiz
•
12th Grade
14 questions
C++ - Loops and Random Numbers
Quiz
•
9th - 12th Grade
15 questions
Cambridge Technicals L3 U2 Information Types
Quiz
•
12th Grade
10 questions
Python- Operators
Quiz
•
12th Grade
15 questions
Attacks Threats & Vulnerabilities (C1)
Quiz
•
9th - 12th Grade
15 questions
Computing Year 7 Hardware and Software Final Quiz QUIZIZZ
Quiz
•
12th Grade
10 questions
Python Alternating Turns
Quiz
•
7th - 12th 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
Discover more resources for Computers
8 questions
2 Step Word Problems
Quiz
•
KG - University
10 questions
Martin Luther King, Jr. For Kids
Interactive video
•
1st - 12th Grade
10 questions
Dr. King's Speech and Its Impact
Interactive video
•
7th - 12th Grade
20 questions
-AR -ER -IR present tense
Quiz
•
10th - 12th Grade
7 questions
Anti-Bullying ARS 15-341
Quiz
•
9th - 12th Grade
13 questions
Model Exponential Growth and Decay Scenarios
Quiz
•
9th - 12th Grade
15 questions
TSI Math Practice Questions
Quiz
•
8th - 12th Grade
24 questions
Identify Properties of Polygons and Quadrilaterals
Quiz
•
9th - 12th Grade
