Java conditions

The quiz presents a Java code that takes an input and prints an output based on some conditions. Take the quiz and test your understanding about conditional statements

download Export
search_insights Statistics
stylus_note White Board
Quran
calculate Calculator
dictionary Dictionary
fullscreen Full Screen
QUESTION OF

volume_mute Read quiz aloud
Views #: 1412
Questions #: 5
Pass Score: 80.0%
Style
Mode

What is the expected result if input is 35?

1 pts
volume_mute
Missing

** lower case answer will be considered correct in this exercise

note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


What is the result if input is -35?

1 pts
volume_mute
Missing

** lower case answer will be considered correct in this exercise

note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


What is the result if input is 0?

1 pts
volume_mute
Missing

** lower case answer will be considered correct in this exercise

note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


What is the input for the code to print "Positive Number"?

1 pts
volume_mute
note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


What is the difference between the following code from the original one in terms of performance?

1 pts
volume_mute
Changing the IF code slightly, but providing the same functionality
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Input number: ");
int input = in.nextInt();
if (input > 0){
System.out.println("Positive Number");
}
if (input < 0){
System.out.println("Negative Number");
}
if (input == 0) {
System.out.println("Zero");
}
}
}
note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation