
Units 2 and 5 Edhesive
Quiz by Jenna Schulman
Feel free to use or edit a copy
includes Teacher and Student dashboards
Measure skillsfrom any curriculum
Measure skills
from any curriculum
Tag the questions with any skills you have. Your dashboard will track each student's mastery of each skill.
With a free account, teachers can
- edit the questions
- save a copy for later
- start a class game
- automatically assign follow-up activities based on students’ scores
- assign as homework
- share a link with colleagues
- print as a bubble sheet
27 questions
Show answers
- Q1Consider the following code: int n = 75; while (n > 0) { System.out.print(n + " " ); n /= 10; } What is output?7550757575...757757060s
- Q2In order for a while loop to stop, the control variable must not change.TrueFalse30s
- Q3The truth table above is the opposite of the && command.TrueFalse30s
- Q4What is wrong with the following code? int x = scan.nextInt(); if (x = 9) System.out.println(x);Nothing is wrong, the code will workit needs a set of { }The x variable is out of scope= is incorrect, it should be ==60s
- Q5The ______ symbol shows an AND operation, where both sides of the command must be true for the entire command to be true.&&andAND&30s
- Q6Assume grade is an int variable. What does !(grade > 90) evaluate to?grade <= 90grade < 90!grade <= !90!grade < !9030s
- Q7What does the following if statement do? if (num1 == Math.abs(num1))Tests if the value in num1 is negativeTests if the value in num1 is greater than or equal to zeroNot enough information is givenTests if the value in num1 is equal to itself30s
- Q8Which code tests if the number in the variable num1 is greater than 15?if (15 < num1)if (15 > num1)if (num1 >= 15)if (num1 <= 15)30s
- Q9The following code is intended to test if the exponent is 8 or less, what is wrong with the code? int base = 2; int exponent = scan.nextInt(); int answer = (int)Math.pow(base, exponent); if (answer <= 256) { System.out.println("exponent is 8 or less");}The <= should be >=Nothing is wrongThe <= should be ==The <= should be <60s
- Q10When do you use an else statement?To do a second calculationTo run some code when an if statement is falseTo input a variableTo end an if statement30s
- Q11What is printed to the screen after the following code is run? int x = 21; if (x > 21) System.out.println(1); else if (x < 21) System.out.println(2); else System.out.println(3);421330s
- Q12Short Circuit Evaluation means that in this code: if (x >= z || val == 97)If x >= z is false it evaluates val == 97If x >= z is false it doesn’t evaluate val == 97If val != 97 is false it doesn’t evaluate x >= zIf x >= z is true it doesn’t evaluate val == 9730s
- Q13What is output to the screen by the following code? int n = 3; while (n < 7) { n++; System.out.print (n + " "); }3456456734567367860s
- Q14What are the first and last numbers printed by the following code? int x = 20; while (x <= 25) { x++; System.out.print (x + " "); }20 2621 2620 2421 2560s
- Q15What does the following loop do? int num = scan.nextInt(); int sum = 0; while ( num > 0) { sum += num % 10; num /= 10; } System.out.print(sum);Finds the lowest common denominator of the number the user enters.Sums each digit of the number the user enters.Finds the remainders of the number the user enters when divided by ten.Adds one to the sum for each digit entered.45s