APDQ 2.1 - 2.3

APDQ 2.1 - 2.3

12th Grade

10 Qs

quiz-placeholder

Similar activities

INTRODUCCION A LA PROGRAMACION

INTRODUCCION A LA PROGRAMACION

6th Grade - University

10 Qs

2025 python class first quiz

2025 python class first quiz

9th Grade - University

10 Qs

Stepwise Refinement

Stepwise Refinement

11th - 12th Grade

13 Qs

ROBOTICS DIWALI CAMP

ROBOTICS DIWALI CAMP

4th - 12th Grade

15 Qs

Python List

Python List

4th Grade - University

15 Qs

Data Security Worksheet

Data Security Worksheet

10th Grade - University

15 Qs

LA5.C5: Branching and Subroutines

LA5.C5: Branching and Subroutines

9th Grade - University

14 Qs

COMPUTER PROGRAMMING Q2_FLOWCHART (2 points each)

COMPUTER PROGRAMMING Q2_FLOWCHART (2 points each)

11th - 12th Grade

10 Qs

APDQ 2.1 - 2.3

APDQ 2.1 - 2.3

Assessment

Quiz

Computers

12th Grade

Practice Problem

Hard

Created by

enorberg@dupage88.net enorberg@dupage88.net

Used 1+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?