Programming Test #1

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

To declare a constant MAX LENGTH with value 99.98, you write :

final double MAX_LENGTH = 99.98;

The main method header is written as:

public static void main(String[] args)

20. What is the printout of the following code: double x = 5.5; int y = (int)x; System.out .println( " x is " + x + "and y is " + y);

x is 5.5 and y is 5

.Which of the following is/are a valid identifier? Select all that applies a. $343 b . class c. 9x d . 8+ 9 e. Radius

$343 Radius

Which of the following expression results in 45.37? a. (int)(45.378 * 100) / 100 b. (int) (45.378 *. 100) / 100.•o c. (int) (45.378 * 100 / 100) d. (int)(45.378) * 100 / 100.0

(int) (45.378 *. 100) / 100.•o

Programming style is important, because___.

-good programming style makes a program more readable -good progranuning style helps reduce progranuning errors

The extension name of a Java bytecode file is:

.class

Math.pow(4, 1 / 2) returns______

1.0

What is the result of 45 / 4?

11

16. Ifyou enter 1 2 3, when you nm this program, what will be the output? import java .utl.Scanner; public class Testl { public static void main( String[) args) { Scanner input = new Scanner(System .in); System .out .print ("Enter three numbers : "); double nurnberl input .nextDouble(); double nurnber2 double nurnber3 input.nextDouble(); input.nextDouble(); II Compute average double average = (nurnberl + nurnber2 + nurnber3) I 3; II Display result System.out .println( average) ; }

2.0

The expression 4 + 20 / (3 - 1) * 2 is evaluated to:

24

Suppose x is 1. What is x after x += 2?

3

8. Which of the following expression results in a value 1? a . 2 % 1 b . 15 % 4 c. 25 % 5 d. 37 % 6

37 % 6

13. What is 24 % 5:

4

What is x after the following statements are executed? int x = 2; int y = 1; x *= y + 1;

4

22. What is the output of the following code snippet? int x = 4; int y = 3; y = x++; System .out .println(y) ;

5

12. Which of the following variable names is invalid a . count b . $count c . count 2 7 d. 67count

67count

Math.pow(2, 3) returns:

8.0

Which of the following statements is/are correct to display Welcome to Java on the console?

System.out .println ("Welcome to Java");

If you forget to put a closing quotation mark on a string, what kind error will be raised?

a compilation error

Suppose a Scanner object is created as follows: Scanner input = new Scanner(System.in); What method do you use to read an int value?

input.nextInt();

21. Identify and fix the error in the following code: public class Quiz2 { public static void main {String[] args) { int i = k +2; System.out.println(i); } }

k is undefined, must include "int k = 0; " before formula


Set pelajaran terkait

Social and Behavioral Research - Belmont Report and It's Principles

View Set

Principles of Financial Accounting Chpt 8

View Set

UNIT 5 CH 23-3 AND 23-4 question from text book

View Set

Chapter 24: Alterations in Genitourinary Function

View Set

Administering IV Medications by Piggyback

View Set

M&B Chapter 11 - Banking Industry: Structure and Competition, CH 11 Banking Industry: Structure and Competition, Chapter 14 Money Supply Process, Practice Problems: M&B, Central Banks and the Federal Reserve System, Chapter 13: Central Banks and the...

View Set