placeholder image to represent content

Units 2 and 5 Edhesive

Quiz by Jenna Schulman

Our brand new solo games combine with your quiz, on the same screen

Correct quiz answers unlock more play!

New Quizalize solo game modes
27 questions
Show answers
  • Q1
    Consider the following code: int n = 75; while (n > 0) { System.out.print(n + " " ); n /= 10; } What is output?
    7550
    757575...
    757
    7570
    60s
  • Q2
    In order for a while loop to stop, the control variable must not change.
    True
    False
    30s
  • Q3
    The truth table above is the opposite of the && command.
    Question Image
    True
    False
    30s
  • Q4
    What is wrong with the following code? int x = scan.nextInt(); if (x = 9) System.out.println(x);
    Nothing is wrong, the code will work
    it needs a set of { }
    The x variable is out of scope
    = is incorrect, it should be ==
    60s
  • Q5
    The ______ symbol shows an AND operation, where both sides of the command must be true for the entire command to be true.
    &&
    and
    AND
    &
    30s
  • Q6
    Assume grade is an int variable. What does !(grade > 90) evaluate to?
    grade <= 90
    grade < 90
    !grade <= !90
    !grade < !90
    30s
  • Q7
    What does the following if statement do? if (num1 == Math.abs(num1))
    Tests if the value in num1 is negative
    Tests if the value in num1 is greater than or equal to zero
    Not enough information is given
    Tests if the value in num1 is equal to itself
    30s
  • Q8
    Which 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
  • Q9
    The 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 wrong
    The <= should be ==
    The <= should be <
    60s
  • Q10
    When do you use an else statement?
    To do a second calculation
    To run some code when an if statement is false
    To input a variable
    To end an if statement
    30s
  • Q11
    What 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);
    4
    2
    1
    3
    30s
  • Q12
    Short Circuit Evaluation means that in this code: if (x >= z || val == 97)
    If x >= z is false it evaluates val == 97
    If x >= z is false it doesn’t evaluate val == 97
    If val != 97 is false it doesn’t evaluate x >= z
    If x >= z is true it doesn’t evaluate val == 97
    30s
  • Q13
    What is output to the screen by the following code? int n = 3; while (n < 7) { n++; System.out.print (n + " "); }
    3456
    4567
    34567
    3678
    60s
  • Q14
    What are the first and last numbers printed by the following code? int x = 20; while (x <= 25) { x++; System.out.print (x + " "); }
    20 26
    21 26
    20 24
    21 25
    60s
  • Q15
    What 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

Teachers give this quiz to your class