Exam 2: Data and Expressions

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

Write a short application that converts inches to centimeters. It should read the number of inches from the user as a floating point number and output the number of inches and the number of centimeters at the end of the program. Note that there are 2.54 centimeters in an inch.

Free
(Essay)
4.9/5
(40)
Correct Answer:
Verified

Which of the following are examples of invalid string literals?

Free
(Multiple Choice)
4.9/5
(38)
Correct Answer:
Verified

E

Consider the following snippet of code: int Consider the following snippet of code: int   What is output by this code? What is output by this code?

Free
(Multiple Choice)
4.9/5
(33)
Correct Answer:
Verified

A

Which of the following is an example of an invalid assignment or declaration statement?

(Multiple Choice)
4.8/5
(38)

Write a single println statement that prints out the following line. "There is Thingumbob shouting!" the Bellman said,

(Short Answer)
4.9/5
(32)

Which of the following lines allows a programmer to use the Scanner class in a Java program?

(Multiple Choice)
4.8/5
(39)

Write a short program that allows the user to enter the year that they were born (as an integer) and outputs the age that they will be at the end of this year. Declare the current year as a constant.

(Essay)
4.9/5
(30)

Suppose your numeric grade is calculated using the following formula: Test 1: 15% Test 2: 15% Final Exam: 30% Homework: 10% Programming Projects: 30% Determine a good variable name to represent each of these values. Write a single expression to compute your grade assuming the variables have been declared and each one stores its value as an integer in the range 0 to 100.

(Essay)
4.8/5
(35)

Explain the difference between the print and the println methods.

(Essay)
5.0/5
(40)

In Java, all floating point literals are assumed to be of type float.

(True/False)
4.8/5
(39)

Information is most likely to be lost in what kind of data conversion?

(Multiple Choice)
4.8/5
(35)

Which of the following data types only allows one of two possible values to be assigned?

(Multiple Choice)
4.8/5
(38)

The Scanner class must be imported using the import statement before it can be used in a program.

(True/False)
4.8/5
(44)

A(n) ________________ is a piece of data that we send to a method.

(Multiple Choice)
4.8/5
(32)

The type of result produced by a mathematical expression depends on the types of the operands.

(True/False)
4.8/5
(40)

In order for a string literal may span multiple lines in the program code.

(True/False)
5.0/5
(38)

Consider the expression: result = 12 + 5 / 2; What value stored in result after this line is executed?

(Multiple Choice)
4.9/5
(31)

Explain why it might not be safe for a programmer to use a narrowing conversion.

(Essay)
4.8/5
(41)

Write a short program that declares a single integer variable called age and assigns it a value equal to your age. Also have it print out your age using the age variable. The output of your program should look similar to the following: I am 30 years old.

(Essay)
4.8/5
(42)

A _______________ is a list of characters in a particular order. Examples include ASCII and Unicode.

(Multiple Choice)
4.9/5
(37)
Showing 1 - 20 of 40
close modal

Filters

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