Java Test 2

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

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

b

Which of the following expressions will yield 0.5? a) 1/2 b) 1.0/2 c) (double) (1/2) d) (double) 1/2

b

Which of the following is the correct expression of character 4? a) 4 b) "4" c) '\0004" d) '4'

b

24 % 5 is __ a) 1 b) 2 c) 3 d) 4 e) 0

d

If you attempt to add an int, a byte, a long and a double the result will be a _______ value. a) byte b) int c) long d) double

d

Suppose x is 1. What is x after x += 2? a) 0 b) 1 c) 2 d) 3 e) 4

d

The Unicode of 'a' is 97. What is the Unicode for 'c'? a) 96 b) 97 c) 98 d) 99

d

To assign a Double variable d to a float variable x, you write ... a) x = (long)d b) x = (int) d c) x = d d) x = (float)d;

d

The following assignment statement refers to the next 2 questions area = Math.PI * radius * radius; 1) What is Math? a) subject b) class c) method d) variable 2) What is PI a) method b) class c) constant d) variable

1 is b. 2 is c

In Java, 12%5 =

2

In Java, 5/2 =

2

What is the result of 45/4 a) 10 b) 11 c) 11.25 d) 12

b

What is x after the following statement? int x = 1; x *= 1 + x; a) 1 b) 2 c) 3 d) 4

b

Will System.out.println((char)4) display 4 a) no b) yes

a

What is the output of relational operators? a) Integer b) Boolean c) Characters d) Double

B

Which of the following operators can operat on a boolean Variable? 1) && 2) == 3)?: 4) += a) 3 & 2 b) 1 & 4 c) 1,2 & 4 d) 1,2 & 3

Pretty sure its c but not completely sure

Which of the following is correct? a) Char a = "a" b) Char a = "aa" c) Char a = 'aa' d) Char a '/"

a

51 - 50 + 109 / 110 is ______. a) 0 b) 1 c) 2 d) 3

b

A Java character is stored in ____________? a) one byte b) two bytes c) three bytes d) four bytes

b

An int variable can hold ______. a) 'x' b) 120 c) 120.0 d) "x" e)"120"

b

In Java, the % refers to a) percenatages b) modulus operator c) division d) data storage

b

The expression (int) (76.0252175 * 100) / 100 evaluates to ___________. a) 76.02 b) 76 c) 76.0252175 d) 76.03

b

Range of byte data type is? a) -128 to 255 b)-128 to 256 c) -128 to 127 d) -127 to 128

c

What is the value of result in the following assignment statement? result = Math.pow(4.0, 2.0); a) 42 b) 24 c) 16 d) 8

c

What is wrong in the following program snippet? final double INTEREST_RATE = 0.069; INTEREST_RATE = 6.9; a) final is not a keyword b) INTEREST_RATE should not be in camel case c) cannot reassign value of constant d) INTEREST_RATE should be 6.9 / 100

c

What will be displayed by the following code? double x = 5.5; int y = (int)x; println("x is " + x + " and y is " + y); a) x is 5 and y is 6 b) x is 6.0 and y is 6.0 c) x is 5.5 and y is 5 d) x is 5.5 and y is 5.0

c

When a data type must contain decimal numbers, assign the type a) Int b) char c) double d) Long int

c

Which of the following assignment statements is correct? a) char c = 'd'; b) char c =100; c) char c = "d"; d) char c = "100";

c

Which of the following is NOT true? a) Both float and double represent real numbers. b) Long can present a larger range of values than double c)The size of long and double is the same d)Char is not a numeric data type

c

Which of these is returned by greater than, and equal to operator? a) integers b) Floating - point numbers c) Boolean d) None of the mentioned

c

What is the value of (double) (5/2)? a) 2 b) 2.5 c) 3 d) 2.0 e) 3.0

d

What is x after the following statement? int x = 2; int y = 1; x *= y + 1; a) 1 b) 2 c) 3 d) 4

d

Which of the following assignment statments is illegal? a) float f = -34F; b)int t = 23; c) short s = 10; d) int t = 4.5;

d

Which of the following expressions result in a value 1? a) 2 % 1 b) 15 % 4 c) 25 % 5 d) 37 % 6

d

-25 % 5 is __ a) 1 b) 2 c) 3 d) 4 e) 0

e

25 % 1 is __ a) 1 b) 2 c) 3 d) 4 e) 0

e


Kaugnay na mga set ng pag-aaral

Maternal Newborn Practice 2019 A***

View Set

CLU3 Lesson 4 chapters 5/6 quiz and def

View Set

giving and get achieve 3000 answers

View Set