Question: If you enter 1 2 3, when you run this program, what will be the output? import java.util.Scanner; public class Test1 { public static void
- If you enter 1 2 3, when you run this program, what will be the output?
import java.util.Scanner;
public class Test1 {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.print(Enter three numbers: );
double number1 = keyboard.nextDouble();
double number2 = keyboard.nextDouble();
double number3 = keyboard.nextDouble();
// Compute average
double average = (number1 + number2 + number3) / 3;
// Display result
System.out.println(average);
}
}
- 1.0
- 3.0
- 4.0
- 2.0
- Assuming the variable score has been assigned the value 13, which of the following statements display XXX?
- if (score > 0) System.out.println (XXX) ;
- if (score > 17) ; System.out.println (XXX) ;
- if (score < 7) ; System.out.println (XXX) ;
- All of the above display XXX;
- What is the output of the following code segment?
t = 0;
if (t > 7)
System.out.println (AAA) ;
System.out.println( BBB );
- AAA
- BBB
- AAABBB
- Nothing
- Which of the following is a valid identifier?
- main
- *calculate
- $Salary
- hello-world
- To declare a constant PI inside a method with value of 3.14 you write
- final PI = 3.14;
- final float PI = 3.14;
- double PI = 3.14;
- final double PI = 3.14;
- A confirm dialog box that displays the options Yes, No and Cancel can be created in a Java program using the showConfirmDialog( ) method in the ________________.
- util.Scanner class
- keyboard.Scanner class
- JOptionPane class
- javax.swing class
- If m = 9, then after n = m++, the value of n is _________.
- 8
- 9
- 10
- 11
- What does the following program segment output?
d = 0;
do
{
System.out.print (d + );
d ++;
} while (d < 2);
- 0
- 01
- 012
- nothing
- After you write and save a Java application file, you ______________ it.
- interpret and then compile
- interpret and then execute
- compile and then resave
- compile and then interpret
- Which is the output of the following code?
b = 1;
while (b < 4)
System.out.print (b + ) ;
- 1
- 123
- 1234
- 11111
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
