Deck 2: Using Data

Full screen (f)
exit full mode
Question
In Java, you use variables of type ____ to store integers, or whole numbers.

A) num
B) double
C) var
D) int
Use Space or
up arrow
down arrow
to flip the card.
Question
You use the ____ data type to hold any single character.

A) single
B) char
C) byte
D) float
Question
Multiplication, division, and remainder always take place after addition or subtraction in an expression.
Question
Once a variable has been declared and initialized, new values may not be assigned to the variable.
Question
A data item is ____ when it cannot be changed while a program is running.

A) variable
B) constant
C) primitive
D) literal
Question
____ refers to the order in which values are used with operators.

A) Associativity
B) Initialization
C) Declaration
D) Floating
Question
A variable can hold more than one value at a time.
Question
In Java, ____ is a built-in class that provides you with the means for storing and manipulating character strings.

A) Escape
B) Type
C) String
D) Character
Question
Primitive types serve as the building blocks for more complex data types, called ____ types.

A) integer
B) literal
C) reference
D) data
Question
You can create a confirm dialog box with five arguments.
Question
You are limited to declaring a maximum of three variables in a single statement.
Question
The expression   boolean isTenLarger = (10 will produce a value of true .
Question
The term parse means to break into component parts.
Question
A ____ is a named memory location that you can use to store a value.

A) cast
B) variable
C) reference
D) primitive
Question
A ____ data type can hold 14 or 15 significant digits of accuracy.

A) double
B) float
C) char
D) boolean
Question
A(n) ____ variable can hold only one of two values: true or false .

A) integer
B) boolean
C) true
D) comparison
Question
The int data type is the most commonly used integer type.
Question
The term ____ refers to the mathematical accuracy of a value.

A) float data
B) real integers
C) significant digits
D) single-precision floating-point number
Question
Even if a statement occupies multiple lines, the statement is not complete until the semicolon is reached.
Question
The byte and short data types occupy less memory and can hold only smaller values.
Question
A(n) ____ dialog box asks a question and provides a text field in which the user can enter a response.

A) question
B) JOptPane
C) confirm
D) input
Question
You use ____ operators to perform calculations with values in your programs.

A) calculation
B) arithmetic
C) integer
D) precedence
Question
You can store any character, including nonprinting characters such as a backspace or a tab, in a(n) ____ variable.

A) int
B) char
C) boolean
D) set
Question
When you write programs that accept ____________________, there is a risk that the user will enter the wrong type of data.
Question
A(n) ____ dialog box typically displays the options Yes, No, and Cancel.

A) confirm
B) input
C) message
D) answer
Question
____________________ forces a value of one data type to be used as a value of another type.
Question
____ occurs when both of the operands are integers.

A) Data modeling
B) Type cast
C) Integer division
D) Unlike assignment
Question
Which escape sequence will move the cursor to the beginning of the current line?

A) \b
B) \r
C) \\
D) \n
Question
What is the value of result after the following statement is executed? int result = 2 + 3 * 4;

A) 9
B) 10
C) 14
D) 20
Question
The characters ____ move the cursor to the next line when used within a println() statement.

A) /n
B) \n
C) .+
D) $
Question
Which of the following is NOT a component of a variable declaration statement?

A) data type identifier
B) symbolic constant
C) variable name
D) ending semicolon
Question
In Java, when a numeric variable is concatenated to a String using the ____, the entire expression becomes a String .

A) plus sign
B) equal sign
C) concatenate statement
D) string statement
Question
Each primitive type in Java has a corresponding class contained in the java.lang package. These classes are called ____ classes.

A) case
B) primitive
C) type-wrapper
D) show
Question
The percent sign is the ____ operator.

A) remainder
B) remaining
C) percentage
D) integer division
Question
A(n) ____________________ is a simple data type.
Question
A(n) ____________________ number contains decimal positions.
Question
When a numeric variable is concatenated to a String , the entire expression becomes a(n) ____ .

A) int
B) constant
C) method
D) String
Question
The ____ is the type to which all operands in an expression are converted so that they are compatible with each other.

A) unifying type
B) data type
C) numbered
D) primitive
Question
You may declare an unlimited number of variables in a statement as long as the variables are ____.

A) the same data type
B) initialized to the same value
C) properly commented
D) floating point numbers
Question
A(n) ____________________ operator compares two items and the result has a Boolean value.
Question
Match between columns
Java consistently specifies their size and format
boolean
Java consistently specifies their size and format
assignment
Java consistently specifies their size and format
garbage value
Java consistently specifies their size and format
primitive type
Java consistently specifies their size and format
operand
Java consistently specifies their size and format
operator precedence
Java consistently specifies their size and format
float
Java consistently specifies their size and format
cast operator
Java consistently specifies their size and format
escape sequence
true or false
boolean
true or false
assignment
true or false
garbage value
true or false
primitive type
true or false
operand
true or false
operator precedence
true or false
float
true or false
cast operator
true or false
escape sequence
Begins with a backslash followed by a character
boolean
Begins with a backslash followed by a character
assignment
Begins with a backslash followed by a character
garbage value
Begins with a backslash followed by a character
primitive type
Begins with a backslash followed by a character
operand
Begins with a backslash followed by a character
operator precedence
Begins with a backslash followed by a character
float
Begins with a backslash followed by a character
cast operator
Begins with a backslash followed by a character
escape sequence
The operator that is represented by an equal sign (=)
boolean
The operator that is represented by an equal sign (=)
assignment
The operator that is represented by an equal sign (=)
garbage value
The operator that is represented by an equal sign (=)
primitive type
The operator that is represented by an equal sign (=)
operand
The operator that is represented by an equal sign (=)
operator precedence
The operator that is represented by an equal sign (=)
float
The operator that is represented by an equal sign (=)
cast operator
The operator that is represented by an equal sign (=)
escape sequence
A programming term for an unknown value
boolean
A programming term for an unknown value
assignment
A programming term for an unknown value
garbage value
A programming term for an unknown value
primitive type
A programming term for an unknown value
operand
A programming term for an unknown value
operator precedence
A programming term for an unknown value
float
A programming term for an unknown value
cast operator
A programming term for an unknown value
escape sequence
Rules for the order in which parts of a mathematical expression are evaluated
boolean
Rules for the order in which parts of a mathematical expression are evaluated
assignment
Rules for the order in which parts of a mathematical expression are evaluated
garbage value
Rules for the order in which parts of a mathematical expression are evaluated
primitive type
Rules for the order in which parts of a mathematical expression are evaluated
operand
Rules for the order in which parts of a mathematical expression are evaluated
operator precedence
Rules for the order in which parts of a mathematical expression are evaluated
float
Rules for the order in which parts of a mathematical expression are evaluated
cast operator
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
Created by placing the desired result type in parentheses
assignment
Created by placing the desired result type in parentheses
garbage value
Created by placing the desired result type in parentheses
primitive type
Created by placing the desired result type in parentheses
operand
Created by placing the desired result type in parentheses
operator precedence
Created by placing the desired result type in parentheses
float
Created by placing the desired result type in parentheses
cast operator
Created by placing the desired result type in parentheses
escape sequence
A floating-point data type
boolean
A floating-point data type
assignment
A floating-point data type
garbage value
A floating-point data type
primitive type
A floating-point data type
operand
A floating-point data type
operator precedence
A floating-point data type
float
A floating-point data type
cast operator
A floating-point data type
escape sequence
A value that can be used on either side of an operator
boolean
A value that can be used on either side of an operator
assignment
A value that can be used on either side of an operator
garbage value
A value that can be used on either side of an operator
primitive type
A value that can be used on either side of an operator
operand
A value that can be used on either side of an operator
operator precedence
A value that can be used on either side of an operator
float
A value that can be used on either side of an operator
cast operator
A value that can be used on either side of an operator
escape sequence
Question
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.
Question
What is the difference between the float data type and the double data type?
Question
Write the statement that will declare and assign two integer variables, salesAmt and costAmt , in a single statement. Assign values of your choice to the variables.
Question
Explain how you can override a unifying type imposed by Java. Show an example.
Question
How can you create and use an input dialog box in Java?
Question
In Java, how is it possible to perform mathematical operations on operands with unlike types?
Question
A variable declaration is a statement that reserves a named memory location. It includes what four elements?
Question
Describe and give an example of operator precedence.
Question
How could you alter the following statement to display "Welcome" on one line and "back" on another line? Show two possible solutions.
System.out.println("Welcome back");
Question
final int COSTPERITEM = 10;
double sales2012 = amtSold * COSTPERITEM;
In the above statements, identify the named constant and describe how a programmer can recognize named constants.
Question
Describe three ways in which a named constant differs from a variable.
Question
char aCharacter = 2;
int aNumber = '2';
In the above statements, what values will be output after a println() statement is executed? Why are the output results different for the two statements?
Question
How would you ask the user to confirm an action using a dialog box?
Question
Define an integer and then list and describe the four integer data data types.
Question
Describe how the use of named constants can provide advantages over the use of literal values.
Question
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.
Question
What is an escape sequence and why would a Java programmer use it to store a character?
Question
Describe why it is important to assign an appropriate data type to variables in an application.
Question
Why is the following relational operator expression invalid? How could you rewrite the statement so that it is valid?
boolean isGradePassing = (grade => 70);
Question
public class YourGrade
{
    public static void main(String[] args)
    {
  int projectPoints = 89;
  System.out.print("Your grade for this class is ");
  System.out.print(projectPoints);
  System.out.println("%");
     }
}
Given the above code, what will be the output at the command prompt?
Question
import javax.swing.JOptionPane;
public class salesJune
{
    public static void main(String[] args)
    {
int storeSales = 250;
    }
}
In the above code, complete the statement that will display a message dialog box that will appear centered on the screen and will display the following text:
Congratulations! June sales were $250!
Question
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);
     }
}
Question
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.
Question
Write the statement that will declare a char data type named testScore that will hold a letter grade of your choice.
Question
100 = salesAmount;
In terms of assignment operators, why is the above statement illegal?
Question
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?
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/67
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 2: Using Data
1
In Java, you use variables of type ____ to store integers, or whole numbers.

A) num
B) double
C) var
D) int
D
2
You use the ____ data type to hold any single character.

A) single
B) char
C) byte
D) float
B
3
Multiplication, division, and remainder always take place after addition or subtraction in an expression.
False
4
Once a variable has been declared and initialized, new values may not be assigned to the variable.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
5
A data item is ____ when it cannot be changed while a program is running.

A) variable
B) constant
C) primitive
D) literal
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
6
____ refers to the order in which values are used with operators.

A) Associativity
B) Initialization
C) Declaration
D) Floating
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
7
A variable can hold more than one value at a time.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
8
In Java, ____ is a built-in class that provides you with the means for storing and manipulating character strings.

A) Escape
B) Type
C) String
D) Character
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
9
Primitive types serve as the building blocks for more complex data types, called ____ types.

A) integer
B) literal
C) reference
D) data
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
10
You can create a confirm dialog box with five arguments.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
11
You are limited to declaring a maximum of three variables in a single statement.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
12
The expression   boolean isTenLarger = (10 will produce a value of true .
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
13
The term parse means to break into component parts.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
14
A ____ is a named memory location that you can use to store a value.

A) cast
B) variable
C) reference
D) primitive
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
15
A ____ data type can hold 14 or 15 significant digits of accuracy.

A) double
B) float
C) char
D) boolean
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
16
A(n) ____ variable can hold only one of two values: true or false .

A) integer
B) boolean
C) true
D) comparison
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
17
The int data type is the most commonly used integer type.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
18
The term ____ refers to the mathematical accuracy of a value.

A) float data
B) real integers
C) significant digits
D) single-precision floating-point number
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
19
Even if a statement occupies multiple lines, the statement is not complete until the semicolon is reached.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
20
The byte and short data types occupy less memory and can hold only smaller values.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
21
A(n) ____ dialog box asks a question and provides a text field in which the user can enter a response.

A) question
B) JOptPane
C) confirm
D) input
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
22
You use ____ operators to perform calculations with values in your programs.

A) calculation
B) arithmetic
C) integer
D) precedence
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
23
You can store any character, including nonprinting characters such as a backspace or a tab, in a(n) ____ variable.

A) int
B) char
C) boolean
D) set
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
24
When you write programs that accept ____________________, there is a risk that the user will enter the wrong type of data.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
25
A(n) ____ dialog box typically displays the options Yes, No, and Cancel.

A) confirm
B) input
C) message
D) answer
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
26
____________________ forces a value of one data type to be used as a value of another type.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
27
____ occurs when both of the operands are integers.

A) Data modeling
B) Type cast
C) Integer division
D) Unlike assignment
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
28
Which escape sequence will move the cursor to the beginning of the current line?

A) \b
B) \r
C) \\
D) \n
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
29
What is the value of result after the following statement is executed? int result = 2 + 3 * 4;

A) 9
B) 10
C) 14
D) 20
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
30
The characters ____ move the cursor to the next line when used within a println() statement.

A) /n
B) \n
C) .+
D) $
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
31
Which of the following is NOT a component of a variable declaration statement?

A) data type identifier
B) symbolic constant
C) variable name
D) ending semicolon
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
32
In Java, when a numeric variable is concatenated to a String using the ____, the entire expression becomes a String .

A) plus sign
B) equal sign
C) concatenate statement
D) string statement
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
33
Each primitive type in Java has a corresponding class contained in the java.lang package. These classes are called ____ classes.

A) case
B) primitive
C) type-wrapper
D) show
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
34
The percent sign is the ____ operator.

A) remainder
B) remaining
C) percentage
D) integer division
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
35
A(n) ____________________ is a simple data type.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
36
A(n) ____________________ number contains decimal positions.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
37
When a numeric variable is concatenated to a String , the entire expression becomes a(n) ____ .

A) int
B) constant
C) method
D) String
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
38
The ____ is the type to which all operands in an expression are converted so that they are compatible with each other.

A) unifying type
B) data type
C) numbered
D) primitive
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
39
You may declare an unlimited number of variables in a statement as long as the variables are ____.

A) the same data type
B) initialized to the same value
C) properly commented
D) floating point numbers
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
40
A(n) ____________________ operator compares two items and the result has a Boolean value.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
41
Match between columns
Java consistently specifies their size and format
boolean
Java consistently specifies their size and format
assignment
Java consistently specifies their size and format
garbage value
Java consistently specifies their size and format
primitive type
Java consistently specifies their size and format
operand
Java consistently specifies their size and format
operator precedence
Java consistently specifies their size and format
float
Java consistently specifies their size and format
cast operator
Java consistently specifies their size and format
escape sequence
true or false
boolean
true or false
assignment
true or false
garbage value
true or false
primitive type
true or false
operand
true or false
operator precedence
true or false
float
true or false
cast operator
true or false
escape sequence
Begins with a backslash followed by a character
boolean
Begins with a backslash followed by a character
assignment
Begins with a backslash followed by a character
garbage value
Begins with a backslash followed by a character
primitive type
Begins with a backslash followed by a character
operand
Begins with a backslash followed by a character
operator precedence
Begins with a backslash followed by a character
float
Begins with a backslash followed by a character
cast operator
Begins with a backslash followed by a character
escape sequence
The operator that is represented by an equal sign (=)
boolean
The operator that is represented by an equal sign (=)
assignment
The operator that is represented by an equal sign (=)
garbage value
The operator that is represented by an equal sign (=)
primitive type
The operator that is represented by an equal sign (=)
operand
The operator that is represented by an equal sign (=)
operator precedence
The operator that is represented by an equal sign (=)
float
The operator that is represented by an equal sign (=)
cast operator
The operator that is represented by an equal sign (=)
escape sequence
A programming term for an unknown value
boolean
A programming term for an unknown value
assignment
A programming term for an unknown value
garbage value
A programming term for an unknown value
primitive type
A programming term for an unknown value
operand
A programming term for an unknown value
operator precedence
A programming term for an unknown value
float
A programming term for an unknown value
cast operator
A programming term for an unknown value
escape sequence
Rules for the order in which parts of a mathematical expression are evaluated
boolean
Rules for the order in which parts of a mathematical expression are evaluated
assignment
Rules for the order in which parts of a mathematical expression are evaluated
garbage value
Rules for the order in which parts of a mathematical expression are evaluated
primitive type
Rules for the order in which parts of a mathematical expression are evaluated
operand
Rules for the order in which parts of a mathematical expression are evaluated
operator precedence
Rules for the order in which parts of a mathematical expression are evaluated
float
Rules for the order in which parts of a mathematical expression are evaluated
cast operator
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
Created by placing the desired result type in parentheses
assignment
Created by placing the desired result type in parentheses
garbage value
Created by placing the desired result type in parentheses
primitive type
Created by placing the desired result type in parentheses
operand
Created by placing the desired result type in parentheses
operator precedence
Created by placing the desired result type in parentheses
float
Created by placing the desired result type in parentheses
cast operator
Created by placing the desired result type in parentheses
escape sequence
A floating-point data type
boolean
A floating-point data type
assignment
A floating-point data type
garbage value
A floating-point data type
primitive type
A floating-point data type
operand
A floating-point data type
operator precedence
A floating-point data type
float
A floating-point data type
cast operator
A floating-point data type
escape sequence
A value that can be used on either side of an operator
boolean
A value that can be used on either side of an operator
assignment
A value that can be used on either side of an operator
garbage value
A value that can be used on either side of an operator
primitive type
A value that can be used on either side of an operator
operand
A value that can be used on either side of an operator
operator precedence
A value that can be used on either side of an operator
float
A value that can be used on either side of an operator
cast operator
A value that can be used on either side of an operator
escape sequence
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
42
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.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
43
What is the difference between the float data type and the double data type?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
44
Write the statement that will declare and assign two integer variables, salesAmt and costAmt , in a single statement. Assign values of your choice to the variables.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
45
Explain how you can override a unifying type imposed by Java. Show an example.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
46
How can you create and use an input dialog box in Java?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
47
In Java, how is it possible to perform mathematical operations on operands with unlike types?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
48
A variable declaration is a statement that reserves a named memory location. It includes what four elements?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
49
Describe and give an example of operator precedence.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
50
How could you alter the following statement to display "Welcome" on one line and "back" on another line? Show two possible solutions.
System.out.println("Welcome back");
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
51
final int COSTPERITEM = 10;
double sales2012 = amtSold * COSTPERITEM;
In the above statements, identify the named constant and describe how a programmer can recognize named constants.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
52
Describe three ways in which a named constant differs from a variable.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
53
char aCharacter = 2;
int aNumber = '2';
In the above statements, what values will be output after a println() statement is executed? Why are the output results different for the two statements?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
54
How would you ask the user to confirm an action using a dialog box?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
55
Define an integer and then list and describe the four integer data data types.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
56
Describe how the use of named constants can provide advantages over the use of literal values.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
57
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.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
58
What is an escape sequence and why would a Java programmer use it to store a character?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
59
Describe why it is important to assign an appropriate data type to variables in an application.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
60
Why is the following relational operator expression invalid? How could you rewrite the statement so that it is valid?
boolean isGradePassing = (grade => 70);
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
61
public class YourGrade
{
    public static void main(String[] args)
    {
  int projectPoints = 89;
  System.out.print("Your grade for this class is ");
  System.out.print(projectPoints);
  System.out.println("%");
     }
}
Given the above code, what will be the output at the command prompt?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
62
import javax.swing.JOptionPane;
public class salesJune
{
    public static void main(String[] args)
    {
int storeSales = 250;
    }
}
In the above code, complete the statement that will display a message dialog box that will appear centered on the screen and will display the following text:
Congratulations! June sales were $250!
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
63
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);
     }
}
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
64
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.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
65
Write the statement that will declare a char data type named testScore that will hold a letter grade of your choice.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
66
100 = salesAmount;
In terms of assignment operators, why is the above statement illegal?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
67
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?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 67 flashcards in this deck.