AP CSA Unit 1: Lesson 6 Questions

0.0(0)
Studied by 6 people
0%Exam Mastery
Build your Mastery score
multiple choiceAP Practice
Supplemental Materials
call kaiCall Kai
Locked
Card Sorting

1/9

flashcard set

Earn XP

Last updated 9:45 PM on 9/24/22
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

10 Terms

1
New cards
Which of the following expressions in Java is equal to 1?
7 % 3
2
New cards
What is printed when the following code has been executed?
int x = 13;
int y = 6;
System.out.println((2 * x + y) % x);
6
3
New cards
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;
4
New cards
Which line of code properly casts a double to an integer?
int n = (int) 6.71;
5
New cards
What is the output when the following code is executed?
int a = 93;
double x = 89.86732;
System.out.println((int) x);
89
6
New cards
What is the output when the following code is executed?
int a = 93;
double x = 89.86732;
System.out.println(a / 3);
31
7
New cards
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.
8
New cards
Executing which of the following lines of code would cause widening conversions to take place?
double a = 19 / 7;
double a = (double) 23 / 6;
9
New cards
What is the output when the following code is executed?
int a = 93;
double x = 89.86732;
System.out.println((double) a);
93.0
10
New cards
What is the value of num2 when the following code is executed?
double num = 34;
int num2 = (int) (34/3);
11