Introduction to Java Programming: Ch. 2 quiz

¡Supera tus tareas y exámenes ahora con Quizwiz!

A variable may be assigned a value only once in the program.

false

The keyword ________ must be used to declare a constant.

final

To declare a constant MAX_LENGHT inside a method with value 99.98, you write?

final double MAX_LENGHT=99.98;

Which od the following assignment statements is illegal?

float f=34.0;

Which of the following assignments statements is incorrect?

i==j==k==1 i=1=j=1=k=1;

pow is a method of in the ________ class.

math

Analyze the following code: public class Test{ public static void main(String[] args){ int month=09; System.out.println("month is " + month); } }

the program has a syntax error, because 09 is an incorrect literal value.

A constant can be defined using the final key word?

true

A veriable must be declared before it can be used?

true

You can always assign a value of int type to a variable of long type without loss of information.

true

To assign a value 1 to variable x, you write?

x=1;

What is y displayed in the following code? public class Test{ public static void main(String[] args){ int x=1; int y =x++ +x; System.out.println("y is " + y); } }

y is 3

variable--

Decrease by 1 and use the original value of the variable in the statement.

-15%-4 is ________.

-3

Numerical operator precedence rule

1. () L to R 2. / * % L to R 3. + - L to R 4. = R to L

What is the value of (double) (5/2)?

2.0

What is the value of double(5/2)?

2.5

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

24

What is printed out? public class Test{ public static void main (String[] args){ int j=0; int I= ++j+j*5; System.out.println("What is i? " +i); } }

6

--variable

Decrease by 1 and use the new value of the variable in the statement.

++variable

Increment by 1 and use the new value of the variable in the statement.

variable++

Increment by 1 and use the original value of the variable in the statement.

Which of the following is a constant, according to Java naming conventions?

MAX_VALUE and COUNT (all words have to contain capital letters , no spaces, and can't start with number.)

Which of these data types require the least amount of memory?

byte

You can cast a double value to _______.

byte, short, int, long, float

Numerical Data type order

byte, short, int, long, float, double


Conjuntos de estudio relacionados

PrepU Questions: Week 16--Respiratory & Skin/Wounds

View Set

Psychology Exam 2 Multiple Choice

View Set

Research Method Exam 2 Study Guide

View Set

A2 EX.4 CH.38 PREP U Musculoskeletal

View Set

Clinical psychology Midterm. Chapters 1-7, 10 & 15

View Set

A&P Chapter 10: Muscles (mastering A&P)

View Set

CE Module 2: English Tense Forms

View Set

Principles and Practices of Argumentation Exam 1 COMM 3310

View Set