Exam 2: Using Data

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

Explain how you can override a unifying type imposed by Java. Show an example.

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

You can purposely override the unifying type imposed by Java by performing a type cast. Type casting forces a value of one data type to be used as a value of another type. To perform a type cast, you use a cast operator, which is created by placing the desired result type in parentheses. Using a cast operator is an explicit conversion. The cast operator is followed by the variable or constant to be cast.
Example:
double bankBalance = 189.66;
float weeklyBudget = (float) (bankBalance / 4);

You can create a confirm dialog box with five arguments.

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

True

Write the statement to declare an uninitialized integer value for salesAmt . Then write the statement to declare a constant named SALESAMT with a value of 20.99.

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

int salesAmt ;
final double SALESAMT = 20.99;

A(n) ____ dialog box typically displays the options Yes, No, and Cancel.

(Multiple Choice)
4.8/5
(29)

Describe how to use the boolean data type. Show two examples of a boolean variable assignment; one that uses true or false and one that uses a relational operator.

(Essay)
4.9/5
(38)

The term parse means to break into component parts.

(True/False)
4.9/5
(43)

____ occurs when both of the operands are integers.

(Multiple Choice)
4.7/5
(41)

In Java, ____ is a built-in class that provides you with the means for storing and manipulating character strings.

(Multiple Choice)
4.8/5
(37)
Match each term with the correct statement below.
Java consistently specifies their size and format
operand
true or false
cast operator
Begins with a backslash followed by a character
operator precedence
Correct Answer:
Verified
Premises:
Responses:
Java consistently specifies their size and format
operand
true or false
cast operator
Begins with a backslash followed by a character
operator precedence
The operator that is represented by an equal sign (=)
float
A programming term for an unknown value
primitive type
Rules for the order in which parts of a mathematical expression are evaluated
escape sequence
Created by placing the desired result type in parentheses
boolean
A floating-point data type
garbage value
A value that can be used on either side of an operator
assignment
(Matching)
4.9/5
(36)

A data item is ____ when it cannot be changed while a program is running.

(Multiple Choice)
4.8/5
(43)

Which of the following is NOT a component of a variable declaration statement?

(Multiple Choice)
5.0/5
(32)

You can store any character, including nonprinting characters such as a backspace or a tab, in a(n) ____ variable.

(Multiple Choice)
4.7/5
(29)

Primitive types serve as the building blocks for more complex data types, called ____ types.

(Multiple Choice)
4.9/5
(42)

What is an escape sequence and why would a Java programmer use it to store a character?

(Essay)
4.8/5
(42)

A variable can hold more than one value at a time.

(True/False)
4.9/5
(38)

____ refers to the order in which values are used with operators.

(Multiple Choice)
4.8/5
(29)

Describe the error message that will be produced when the following code is compiled. public class SalesOct {     public static void main(String[] args)     { int salesAmt; System.out.print("October sales are $"); System.out.println(salesAmt);      } }

(Essay)
5.0/5
(39)

public class EndValue {     public static void main(String[] args)     { int aByte = 940;    System.out.print("The ending value is "+ aByte);     } } When the above code is compiled, what error message will be generated and why?

(Essay)
4.9/5
(34)

Describe how the Scanner class works with the System.in object in order to provide flexibility. Provide an example of using the Scanner class with System.in.

(Essay)
4.8/5
(33)

When you write programs that accept ____________________, there is a risk that the user will enter the wrong type of data.

(Short Answer)
4.8/5
(38)
Showing 1 - 20 of 67
close modal

Filters

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