Filters
Question type

Study Flashcards

If x has been declared an int, which of the following statements is invalid?


A) x = 0;
B) x = -59832;
C) x = 1,000;
D) x = 592

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

What will be displayed as a result of executing the following code? public class test { Public static void main(String[ ] args) { Int value1 = 9; System.out.println(value1) ; Int value2 = 45; System.out.println(value2) ; System.out.println(value3) ; Value = 16; } }


A) 9
45
16
B) 94516
C) 9 45 16
D) Nothing. This is an error

E) All of the above
F) B) and D)

Correct Answer

verifed

verified

The boolean data type may contain which of the following range of values?


A) -128 to + 127
B) true or false
C) -2,147,483,648 to +2,147,483,647
D) -32,768 to +32,767

E) A) and D)
F) B) and C)

Correct Answer

verifed

verified

Which of the following is not a rule that must be followed when naming identifiers?


A) The first character must be one of the letters a-z, A-Z, and underscore or a dollar sign.
B) Identifiers can contain spaces.
C) Uppercase and lowercase characters are distinct.
D) After the first character, you may use the letters a-z, A-Z, the underscore, a dollar sign, or digits 0-9.

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

The Java API provides a class named Math that contains numerous methods which are useful for performing complex mathematical operations.

A) True
B) False

Correct Answer

verifed

verified

Named constants are initialized with a value and that value cannot change during the execution of the program.

A) True
B) False

Correct Answer

verifed

verified

What is the result of the following expression? 17 % 3 * 2 - 12 + 15


A) 105
B) 12
C) 7
D) 8

E) B) and C)
F) C) and D)

Correct Answer

verifed

verified

Both character and string literals can be assigned to a char variable.

A) True
B) False

Correct Answer

verifed

verified

A Java program will not compile unless it contains the correct line numbers.

A) True
B) False

Correct Answer

verifed

verified

Which of the following cannot be used as identifiers in Java?


A) variable names
B) class names
C) key words
D) objects

E) None of the above
F) A) and B)

Correct Answer

verifed

verified

What is the value of z after the following code is executed? int x = 5, y = 28; Float z; Z = (float) (y / x) ;


A) 5.6
B) 3.0
C) 5.0
D) 5.60

E) A) and B)
F) All of the above

Correct Answer

verifed

verified

The primitive data types only allow a(n) __________ to hold a single value.


A) class
B) literal
C) object
D) variable

E) All of the above
F) B) and D)

Correct Answer

verifed

verified

Which of the following is not a valid Java comment?


A) /** Comment one */
B) */ Comment two /*
C) // Comment three
D) /* Comment four */

E) A) and D)
F) A) and C)

Correct Answer

verifed

verified

What would be printed out as a result of the following code? System.out.println("The quick brown fox" + "jumped over the \n" "slow moving hen.") ;


A) The quick brown fox jumped over the \nslow moving hen.
B) The quick brown fox jumped over the
Slow moving hen.
C) The quick brown fox
Jumped over the
Slow moving hen.
D) Nothing - this is an error

E) None of the above
F) A) and B)

Correct Answer

verifed

verified

Character literals are enclosed in __________ and string literals are enclosed in __________.


A) single quotes, double quotes
B) double quotes, single quotes
C) single quotes, single quotes
D) double quotes, double quotes

E) B) and D)
F) A) and D)

Correct Answer

verifed

verified

Class names and key words are examples of variables.

A) True
B) False

Correct Answer

verifed

verified

Which of the following statements correctly creates a Scanner object for keyboard input?


A) Scanner kbd = new Scanner(System.keyboard) ;
B) Scanner keyboard = new Scanner(System.in) ;
C) Scanner keyboard(System.in) ;
D) Keyboard scanner = new Keyboard(System.in) ;

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

What output will be displayed as a result of executing the following code? int x = 5, y = 20; X += 32; Y /= 4; System.out.println("x = " + x + ", y = " + y) ;


A) x = 160, y = 80
B) x = 32, y = 4
C) x = 37, y = 5
D) x = 9, y = 52

E) A) and D)
F) A) and C)

Correct Answer

verifed

verified

When the + operator is used with strings, it is known as the


A) assignment operator
B) string concatenation operator
C) addition operator
D) combines assignment operator

E) A) and B)
F) All of the above

Correct Answer

verifed

verified

The System.out.printf method allows you to format output in a variety of ways.

A) True
B) False

Correct Answer

verifed

verified

Showing 21 - 40 of 52

Related Exams

Show Answer