AP Computer Science A: Unit 1

0.0(0)
studied byStudied by 32 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/19

Last updated 5:17 AM on 9/22/25
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

20 Terms

1
New cards

Assuming that scan is a properly initialized Scanner variable, which of the following correctly inputs a String?

String val = scan.nextLine();

2
New cards

Consider the following code:

int x = -3;

x--;

System.out.println(x);

What is output?

-4

3
New cards

Which of the following data types would be most appropriate to use when recording whether a switch is in the "on" or "off" position?

boolean

4
New cards

Which of the following is NOT a primitive data type?

String

5
New cards

What is output by the following code?

int a = 91;

System.out.println(a / 2);

45

6
New cards

Which of the following is a legal variable name in Java?

ans

7
New cards

What is (6 % 2) * 7?

0

8
New cards

Which of the following would properly create A and B as integer variables?

int A;

int B;

9
New cards

Which of the following correctly stores the word umbrella in a variable called stuff?

String stuff = "umbrella";

10
New cards

Consider the following code:

int c = 3 - 37 % 2;

System.out.println(c);

What is output?

2

11
New cards

Consider the following code:

int x = 9;

int y = 6;

System.out.println( (x*y)/x );

What is output?

6

12
New cards

Consider the following variable declaration:

double y = 52;

Does a cast need to be added so this code will compile and run successfully? ______. If so, what should be typed for this cast? _______

no, nothing

13
New cards

For which of the following would modular division be LEAST likely to be useful?

converting decimals to whole numbers

14
New cards

The following code is intended to input three integers and print the average. What is a potential problem with the code as written?

System.out.println("Please enter three integers: ");

int a = scan.nextInt();

int b = scan.nextInt();

int c = scan.nextInt();

System.out.println("The average is: " + (a + b + c) / 3);

It needs a cast so that the decimal portion will be shown.

15
New cards

What is output by the following code?

int val = -2;

val++;

val--;

val++;

val++;

val++;

val--;

val++;

System.out.println(val);

1

16
New cards

What is the value of w after executing this segment of code?

int w = 18;

w += 18;

36

17
New cards

When might you encounter a problem with integer overflow?

When trying to store an integer which is too big to be stored in an int variable

18
New cards

There are two integer variables in our program, minutes and hours, which represents time. If in the program, we increase the number of minutes by one, which of the following lines of code will correctly update hour and minutes?

hours = hours + minutes / 60;

minutes = minutes % 60;

19
New cards

Correct the following code so that q stores the nearest integer below 82.3847.

int q = 82.3847;

int q = (int) 82.3847;

20
New cards

Which of the following will print the ones column of an integer stored in x?

System.out.print(x % 10);

Explore top notes

note
1 Corinthians Lecture
Updated 1180d ago
0.0(0)
note
Vietnam War
Updated 765d ago
0.0(0)
note
Developmental Psych Chapter 19
Updated 1266d ago
0.0(0)
note
business + economics
Updated 139d ago
0.0(0)
note
4.17 The Early Romantics
Updated 1186d ago
0.0(0)
note
Psych Lesson 1
Updated 1279d ago
0.0(0)
note
Waves
Updated 287d ago
0.0(0)
note
1 Corinthians Lecture
Updated 1180d ago
0.0(0)
note
Vietnam War
Updated 765d ago
0.0(0)
note
Developmental Psych Chapter 19
Updated 1266d ago
0.0(0)
note
business + economics
Updated 139d ago
0.0(0)
note
4.17 The Early Romantics
Updated 1186d ago
0.0(0)
note
Psych Lesson 1
Updated 1279d ago
0.0(0)
note
Waves
Updated 287d ago
0.0(0)

Explore top flashcards

flashcards
real biologs
40
Updated 83d ago
0.0(0)
flashcards
Cardiovascular Review
42
Updated 1221d ago
0.0(0)
flashcards
religion test
30
Updated 1205d ago
0.0(0)
flashcards
NSTP MIDTERMS EXAM
92
Updated 863d ago
0.0(0)
flashcards
Unidad 4A Vocabulario - A Comer
32
Updated 736d ago
0.0(0)
flashcards
Latin Exam Vocabulary
437
Updated 295d ago
0.0(0)
flashcards
Vocab Quest 5
30
Updated 1074d ago
0.0(0)
flashcards
real biologs
40
Updated 83d ago
0.0(0)
flashcards
Cardiovascular Review
42
Updated 1221d ago
0.0(0)
flashcards
religion test
30
Updated 1205d ago
0.0(0)
flashcards
NSTP MIDTERMS EXAM
92
Updated 863d ago
0.0(0)
flashcards
Unidad 4A Vocabulario - A Comer
32
Updated 736d ago
0.0(0)
flashcards
Latin Exam Vocabulary
437
Updated 295d ago
0.0(0)
flashcards
Vocab Quest 5
30
Updated 1074d ago
0.0(0)