Services
Discover
Homeschooling
Ask a Question
Log in
Sign up
Filters
Done
Question type:
Essay
Multiple Choice
Short Answer
True False
Matching
Topic
Computing
Study Set
Big Java Late Objects
Quiz 3: Decisionseasy
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 21
Multiple Choice
Consider the following code snippet. Assuming that the user inputs 75 as the age, what is the output? Int age = 0; Scanner in = new Scanner(System.in) ; System.out.print("Please enter your age: ") ; Age = in.nextInt() ; If (age < 10) { System.out.print("Child ") ; } If (age < 30) { System.out.print("Young adult ") ; } If (age < 70) { System.out.print("Old ") ; } If (age < 100) { System.out.print("Impressively old ") ; }
Question 22
Multiple Choice
What is the value of the price variable after the following code snippet is executed? Int price = 42; If (price < 40) { Price = price + 10; } If (price > 30) { Price = price * 2; } If (price < 100) { Price = price - 20; }
Question 23
Multiple Choice
Consider the following code snippet. What is the potential problem with the if statement? Double average; Average = (g1 + g2 + g3 + g4) / 4.0; If (average == 90.0) { System.out.println("You earned an A in the class!") ; }
Question 24
Multiple Choice
Assuming that a user enters 5 as the value for num, what is the output of the following code snippet? Int num = 0; Scanner in = new Scanner(System.in) ; System.out.print("Enter a number: ") ; Num = in.nextInt() ; If (num < 50) { Num = num + 5; } If (num < 10) { Num = num - 2; } If (num > 5) { Num++; } Else { Num--; } System.out.println(num) ;
Question 25
Multiple Choice
The two strings "Aardvark" and "Aardvandermeer" are exactly the same up to the first six letters. What is their correct lexicographical ordering?
Question 26
Multiple Choice
What is the output of the following code snippet? String str1 = "her"; String str2 = "cart"; If (str1.compareTo(str2) < 0) { System.out.print(str2) ; } Else { System.out.print(str1) ; }
Question 27
Multiple Choice
Which of the following options is a legally correct expression for inverting a condition?
Question 28
Multiple Choice
Write an if-statement condition that is true if the length of string s1 is greater than 42.
Question 29
Multiple Choice
What is the problem with the following if statement? Double count = 15.0; If (count / 3.0) { System.out.println("The value of count is ") ; }
Question 30
Multiple Choice
Which condition, when supplied in the if statement below in place of (. . .) , will correctly protect against division by zero? If (. . .) { Result = grade / num; System.out.println("Just avoided division by zero!") ; }
Question 31
Multiple Choice
Consider the following code snippet. Assuming that the user enters first 20 and then 12 as the two input values, what is the output of the code snippet? Int num1 = 0; Int num2 = 0; Int num3 = 0; Int num4 = 0; Int num5 = 0; Scanner in = new Scanner(System.in) ; System.out.print("Enter a number: ") ; Num1 = in.nextInt() ; System.out.print("Enter a number: ") ; Num2 = in.nextInt() ; If (num1 < num2) { Num3 = num1; } Else { Num3 = num2; } If (num1 < num2 + 10) { Num4 = num1; } Else if (num1 < num2 + 20) { Num5 = num1; } System.out.println("num1 = " + num1 + " num2 = " + num2 + " num3 = " + num3 + " num4 = " + num4 + " num5 = " + num5) ;
Question 32
Multiple Choice
What is the output of the following code snippet? Int num = 100; If (num != 100) { System.out.println("100") ; } Else { System.out.println("Not 100") ; }
Question 33
Multiple Choice
In a switch statement, if a break statement is missing
Question 34
Multiple Choice
What is the conditional required to check whether the length of a string s1 is odd?
Question 35
Multiple Choice
Assuming that the user enters 60 as the input, what is the output after running the following code snippet? Int num = 0; Scanner in = new Scanner(System.in) ; System.out.print("Enter a number: ") ; Num = in.nextInt() ; If (num < 10) { System.out.println("Too small!") ; } Else if (num < 50) { System.out.println("Intermediate!") ; } Else if (num < 100) { System.out.println("High!") ; } Else { System.out.println("Too high!") ; }
Question 36
Multiple Choice
Consider a situation where multiple if statements are combined into a chain to evaluate a complex condition. Which of the following reserved words is used to define the branch to be executed when none of the conditions are true?