Exam 2: Data and Expressions

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

An employer has decided to award a weekly pay raise to all employees by taking the square root of the difference between his weight and the employee's weight. For instance, an employee who weighs 16 pounds less than the employer will get a $4 per week raise. The raise should be in whole dollars (an int). Assume that employerWeight and employeeWeight are both int variables that have been input. Write an assignment statement to compute the int value for raise.

(Essay)
4.8/5
(32)

If String name = "George W. Bush"; then the instruction name.length(); will return 14.

(True/False)
4.9/5
(33)

If String a = "ABCD" and String b = "abcd" then a.equals(b); returns false but a.equalsIgnoreCase(b); returns true.

(True/False)
4.7/5
(46)

If x is the String "Hi There", then x.toUpperCase().toLowerCase(); will return the original value of x.

(True/False)
4.7/5
(26)

Since you cannot take the square root of a negative number, which of the following could you use to find the square root of the variable x?

(Multiple Choice)
5.0/5
(39)

Given the double likelihood = 0.013885 and given DecimalFormat dformatter = DecimalFormat("0.00##"); What would be the output if you execute the following: System.out.println(df.format(likelihood));

(Multiple Choice)
4.9/5
(39)

You cannot cast a String to be a char and you cannot cast a String which stores a number to be an int, float, or double.

(True/False)
4.7/5
(36)

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. How many lines of output are provided by this program?

(Multiple Choice)
4.8/5
(33)

Which library package would you import to use NumberFormat and DecimalFormat?

(Multiple Choice)
4.8/5
(35)

Write an output statement which will output the following characters exactly as shown: / ' \" / ' \

(Essay)
4.9/5
(38)

If you want to store the value "Harry Potter" in the String variable name, which of the following statements could you use?

(Multiple Choice)
5.0/5
(32)

Explain what the following statement computes: int z = (int)Math.ceil(Math.sqrt(x)/Math.sqrt(y));

(Essay)
4.9/5
(35)

If x is an int and y is a float, which of the following statements is not a legal assignment statement?

(Multiple Choice)
5.0/5
(37)

There are three ways that data conversion may occur: by assignment, by promotion, and by casting.

(True/False)
4.9/5
(33)

Using getCurrencyInstance() formats a variable, automatically inserting

(Multiple Choice)
4.9/5
(40)

Assume that x, y, and z are all ints equal to 50, 20, and 6 respectively. What is the result of: x / y / z

(Multiple Choice)
4.9/5
(40)

Given two points in an applet represented by the four int variables x1, y1, x2 and y2, write a paint method to draw a line between the two points and write the location of the two points next to the two points.

(Essay)
4.8/5
(35)

If the String major = "Computer Science", what is returned by major.charAt(1)?

(Multiple Choice)
4.9/5
(32)

A Java variable is the name of a

(Multiple Choice)
4.9/5
(31)

As presented in the Software Failure section of the text, the root cause of the Mars Climate Orbiter problem was

(Multiple Choice)
4.8/5
(35)
Showing 41 - 60 of 67
close modal

Filters

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