AP CSA Unit 1: Lesson 6 Questions

studied byStudied by 6 people
0.0(0)
Get a hint
Hint

Which of the following expressions in Java is equal to 1?

1 / 9

flashcard set

Earn XP

Description and Tags

10 Terms

1

Which of the following expressions in Java is equal to 1?

7 % 3

New cards
2

What is printed when the following code has been executed? int x = 13; int y = 6; System.out.println((2 * x + y) % x);

6

New cards
3

Consider the following program which is intended to get the amount of time (in seconds) it took someone to do one of their chores and then converts it to minutes and seconds. Scanner scan = new Scanner(System.in);int m = 0; int s; System.out.print("How many seconds did it take you to do one of your chores? "); s = scan.nextInt(); /* missing code */ System.out.println("It took you " + m + " minutes and " + s + " seconds."); Which of the following could replace the missing code so that it all works as intended?

m = s / 60; s = s % 60;

New cards
4

Which line of code properly casts a double to an integer?

int n = (int) 6.71;

New cards
5

What is the output when the following code is executed? int a = 93; double x = 89.86732; System.out.println((int) x);

89

New cards
6

What is the output when the following code is executed? int a = 93; double x = 89.86732; System.out.println(a / 3);

31

New cards
7

What is one reason we would use numeric casts in Java?

There is a chance that you lose data when you convert from a larger data type to a smaller data type.

New cards
8

Executing which of the following lines of code would cause widening conversions to take place?

double a = 19 / 7; double a = (double) 23 / 6;

New cards
9

What is the output when the following code is executed? int a = 93; double x = 89.86732; System.out.println((double) a);

93.0

New cards
10

What is the value of num2 when the following code is executed? double num = 34; int num2 = (int) (34/3);

11

New cards

Explore top notes

note Note
studied byStudied by 23 people
Updated ... ago
5.0 Stars(2)
note Note
studied byStudied by 41 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 11 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 46 people
Updated ... ago
4.0 Stars(1)
note Note
studied byStudied by 91 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 9 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 26 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 30060 people
Updated ... ago
4.4 Stars(24)

Explore top flashcards

flashcards Flashcard36 terms
studied byStudied by 9 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard117 terms
studied byStudied by 66 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard27 terms
studied byStudied by 16 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard103 terms
studied byStudied by 16 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard47 terms
studied byStudied by 7 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard29 terms
studied byStudied by 15 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard46 terms
studied byStudied by 4 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard40 terms
studied byStudied by 65 people
Updated ... ago
5.0 Stars(1)