Questions from Starting Out With Java


Q: Which is a character literal, 'B' or "B"?

Which is a character literal, 'B' or "B"?

See Answer

Q: What is wrong with the following statement? char letter =

What is wrong with the following statement? char letter = "Z";

See Answer

Q: Complete the following table by writing the value of each expression in

Complete the following table by writing the value of each expression in the Value column.

See Answer

Q: Is the division statement in the following code an example of integer

Is the division statement in the following code an example of integer division or floating-point division? What value will be stored in portion? double portion; portion = 70 / 3;

See Answer

Q: Write statements using combined assignment operators to perform the following:

Write statements using combined assignment operators to perform the following: 1. Add 6 to x 2. Subtract 4 from amount 3. Multiply y by 4 4. Divide total by 27 5. Store in x the remainder of x divided...

See Answer

Q: The following declaration appears in a program: short totalPay,

The following declaration appears in a program: short totalPay, basePay = 500, bonus = 1000; The following statement appears in the same program: totalPay = basePay + bonus; 1. Will the statement comp...

See Answer

Q: The variable a is a float and the variable b is a

The variable a is a float and the variable b is a double. Write a statement that will assign the value of b to a without causing an error when the program is compiled.

See Answer

Q: Write a statement that declares a String variable named city. The

Write a statement that declares a String variable named city. The variable should be initialized so it references an object with the string “San Franciscoâ€.

See Answer

Q: Assume primaryStage references the Stage object, and scene references your Scene

Assume primaryStage references the Stage object, and scene references your Scene object. Write a statement that adds the scene to the stage.

See Answer

Q: Assume that stringLength is an int variable. Write a statement that

Assume that stringLength is an int variable. Write a statement that stores the length of the string referenced by the city variable in stringLength.

See Answer