Exam 2: Data and Expressions

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

What is the value of z after the following assignment statement is executed? float z = 5/10;

(Multiple Choice)
4.9/5
(34)

How do the statements "import java.util.*;" and "import java.util.Random;" differ from each other?

(Essay)
4.8/5
(37)

Assume that x and y are ints equal to 10 and 5 respectively. What is the output of the following statement? System.out.println("" + x + y);

(Multiple Choice)
4.7/5
(38)

Which of the following would return the last character of the String x?

(Multiple Choice)
4.8/5
(33)

In order to create a constant, which of the following Java reserved words is used?

(Multiple Choice)
4.9/5
(35)

Provide three examples of code using assignment statements where one assignment statement would result in a syntax error, one would result in a logical error, and one would result in a run-time error.

(Essay)
4.8/5
(40)

What will be the value of z after the following statement is executed? int z = 50 /10.00;

(Multiple Choice)
4.8/5
(28)

Which of the following situations would require a cast?

(Multiple Choice)
4.9/5
(45)

A variable of type boolean will store either a 0 or a 1.

(True/False)
4.8/5
(47)

In Java, 'a' and 'A' are considered to be different values.

(True/False)
4.9/5
(34)

The word println is a(n)

(Multiple Choice)
4.7/5
(35)

Example Code Ch 02-1 public class Questions1_4 { public static void main(String[] args) { System.out.print("Here"); System.out.println("There " + "Everywhere"); System.out.println("But not" + "in Texas"); } } -Refer to the class definition in Example Code Ch 02-1. A reasonable documentation comment for this program might be

(Multiple Choice)
4.8/5
(35)

A double is wider than a float and a float is wider than an int.

(True/False)
4.8/5
(36)

Assume that a = "1", b = "2", y = 3, and z = 4. How do the following two statements differ? System.out.println(a + b + y + z); System.out.println(y + z + a + b);

(Essay)
4.8/5
(40)

Provide an example of how you might use a boolean, a float, a char, a String, and an int.

(Essay)
4.8/5
(40)

Using the various String methods, manipulate a String called current to be the last character of current followed by the remainder of its characters in order, placing the result in a String called rearranged.

(Essay)
4.8/5
(30)

If you want to output the text "hi there" including the quote marks, which of the following would you use?

(Multiple Choice)
4.8/5
(33)

Write a set of instructions to prompt the user for an int value and input it using the Scanner class into the variable x and prompt the user for a float value and input it using the Scanner class into the variable y.

(Essay)
5.0/5
(47)

Write a program that will input some number of cents (less than 100) and output the number of quarters, dimes, nickels and pennies needed to add up to that amount.

(Essay)
4.7/5
(31)

Example Code Ch 02-1 public class Questions1_4 { public static void main(String[] args) { System.out.print("Here"); System.out.println("There " + "Everywhere"); System.out.println("But not" + "in Texas"); } } -Refer to the class definition in Example Code Ch 02-1. The program will print the word "Here" and then print

(Multiple Choice)
4.8/5
(39)
Showing 21 - 40 of 67
close modal

Filters

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