Exam 2: Basic Elements of Java

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

An identifier can be any sequence of characters and integers.

Free
(True/False)
4.9/5
(41)
Correct Answer:
Verified

False

In Java, a period is used to terminate a statement.

Free
(True/False)
4.9/5
(37)
Correct Answer:
Verified

False

Consider the following program. // Insertion Point 1 public class CircleArea {// Insertion Point 2 static final float PI = 3.14 public static void main(String[]args) {//Insertion Point 3 float r = 2.0; float area; area = PI * r * r; System.out.println("Area = " + area);} // Insertion Point 4} In the above code, where do the import statements belong?

Free
(Multiple Choice)
5.0/5
(32)
Correct Answer:
Verified

A

Which of the following is a valid char value?

(Multiple Choice)
4.9/5
(37)

The length of the string "first java program" is:

(Multiple Choice)
4.9/5
(38)

Suppose that index is an int variable. The statement index = index + 1; is equivalent to index++;

(True/False)
4.9/5
(37)

Which of the following is NOT a reserved word in Java?

(Multiple Choice)
4.7/5
(40)

Suppose x = 18.6. The output of the statement System.out.println((int)(x) / 3); is 6.

(True/False)
4.9/5
(34)

What is the output of the following statement? System.out.println("Welcome \n Home");

(Multiple Choice)
4.8/5
(35)

When evaluating a mixed expression, all integer operands are converted to floating-point numbers with the decimal part of zero.

(True/False)
4.8/5
(36)

The data type float is a floating-point data type.

(True/False)
4.9/5
(34)

The value of the expression 14 % 3 is ____.

(Multiple Choice)
4.7/5
(35)

The expression (int)8.7 evaluates to ____.

(Multiple Choice)
4.9/5
(39)

Suppose console is a Scanner object initialized with the standard input device. The expression console.nextInt(); is used to read one int value and the expression console.nextDouble(); is used to read two int values.

(True/False)
4.9/5
(32)

Java automatically initializes all variables.

(True/False)
4.7/5
(42)

Which of the following statements about a named constant is NOT true?

(Multiple Choice)
4.8/5
(36)

Which of the following is the newline character?

(Multiple Choice)
4.7/5
(40)

Suppose x = 4 and y = 2. If the statement x *= y; is executed once, what is the value of x?

(Multiple Choice)
4.9/5
(42)

The memory allocated for a double value is ____ bytes.

(Multiple Choice)
4.9/5
(39)

Suppose console is a Scanner object initialized with the standard input device and feet and inches are int variables. Consider the following statements: feet = console.nextInt(); inches = console.nextInt(); These statements require the value of feet and inches to be input on separate lines.

(True/False)
4.8/5
(30)
Showing 1 - 20 of 50
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)