Java Chapters 1-4 – Flashcards
Unlock all answers in this set
Unlock answersquestion
This part of the computer fetches instructions, carries out the operations commanded by the instructions, and produces some outcome or resultant information
answer
CPU
question
A byte is made up of eight
answer
bits
question
Each byte is assigned a unique
answer
address
question
This type of memory can hold data for long periods of time-even when there is no power to the computer
answer
secondary storage
question
If you were to look at a machine language program, you would see
answer
a stream of binary numbers
question
This type of program is designed to be transmitted over the Internet and run in a Web browser
answer
applet
question
These are words that have a special meaning in the programming language
answer
key words
question
These are symbols or words that perform operations on one or more operands
answer
operators
question
These characters serve specific purposes, such as marking the beginning or ending of a statement, or separating items in a list
answer
punctuation
question
These are words or names that are used to identify storage locations in memory and parts of the program that are created by the programmer
answer
programmer-defined names
question
These are rules that must be followed when writing a program
answer
syntax
question
This is a named storage location in the computer's memory
answer
variable
question
The Java compiler generates
answer
byte code
question
JVM stands for
answer
Java Virtual Machine
question
Every complete statement ends with a
answer
semicolon
question
The following data: 72 'A' "Hello World" 2.8712 are all examples of
answer
literals
question
A group of statements, such as the contents of a class or a method, are enclosed in
answer
braces { }
question
Which of the following are not valid assignment statements total=9; 72=amount; profit=129 letter='W';
answer
72=amount; profit=129
question
Which of the following are not valid println statements System.out.println + "Hello World"; System.out.println("Have a nice day"); out.System.println(value); println.out(Programming is great fun);
answer
System.out.println + "Hello World"; out.System.println(value); println.out(Programming is great fun);
question
The negotiation operator is
answer
unary
question
This key word is used to declare a named constant
answer
final
question
These characters mark the beginning of a multi-line comment
answer
/*
question
These characters mark the beginning of a single-line comment
answer
//
question
These characters mark the beginning of a documentation comment
answer
/**
question
Which Scanner class method would you use to read a string as input
answer
nextLine
question
Which Scanner class method would you use to read a double as input
answer
nextDouble
question
You can use this class to display dialog boxes
answer
JOptionPane
question
When Java converts a lower-ranked value to a higher-ranked type, it is called a
answer
widening conversion
question
This type of operator lets you manually convert a value, even if it means that a narrowing conversion will take place
answer
cast
question
A left brace in a Java program is always followed by a right brace later in the program
answer
true
question
A variable must be declared before it can be used
answer
true
question
Variable names may begin with a number
answer
false
question
You cannot change the value of a variable whose declaration uses the final key word
answer
true
question
Comments that begin with // can be processed by javadoc
answer
false
question
If one of an operator's operands is a double, and the other operand is an int, Java will automatically convert the value of the double to an int
answer
false
question
The if statement is an example of a
answer
decision structure
question
This type of expression has a value of either true or false
answer
boolean expression
question
>,<, and == are
answer
relational operators
question
&&,||, and ! are
answer
logical operators
question
This is an empty statement that does nothing
answer
null statement
question
To create a block of statements, you enclose the statements in these
answer
braces{ }
question
This is a boolean variable that signals when some condition exists in the program
answer
flag
question
How does the character 'A' compare to the character 'B'
answer
'A' is less than 'B'
question
This is an if statement that appears inside another if statement
answer
nested if statement
question
An else clause always goes with
answer
the closest previous if clause that doesn't already have its own else clause
question
When determining whether a number is inside a range, it's best to use this operand
answer
&&
question
This determines whether two different String objects contain the same string
answer
the equals method
question
The conditional operand takes this many operands
answer
three
question
This section of a switch statement is branched to if none of the case expressions match the switch expression
answer
default
question
You can use this method to display formatted output in a console window
answer
System.out.printf
question
The = operator and the == operator perform the same operation
answer
false
question
A conditionally executed statement should be indented one level from the if clause
answer
true
question
All lines in a conditionally executed block should be indented one level
answer
true
question
When an if statement is nested in the if clause of another statement, the only time the inner if statement is executed is when the boolean expression of the outer if statement is true
answer
true
question
When an if statement is nested in the else clause of another statement, the only time the inner if statement is executed is when the boolean expression of the outer if statement is true
answer
false
question
The scope of a variable is limited to the block in which it is defined
answer
true
question
What will the println statement in the following program segment display int x=5; System.out.println(x++);
answer
5
question
What will the println statement in the following program segment display int x=5; System.out.println(++x);
answer
6
question
In the expression number++, the ++ operator is in what mode
answer
postfix
question
What is each repetition of a loop known as
answer
iteration
question
This is a variable that controls the number of iterations performed by a loop
answer
loop control variable
question
The while loop is this type of loop
answer
pretest
question
The do-while loop is this type of loop
answer
posttest
question
The for loop is this type of loop
answer
pretest
question
This type of loop has no way of ending and repeats until the program is interrupted
answer
infinite
question
This type of loop always executes at least once
answer
do-while
question
This expression is executed by the for loop only once, regardless of the number of iterations
answer
initialization expression
question
This is a variable that keeps a running total
answer
accumulator
question
This is a special value that signals when there are no more items from a list of items to be processed; this value cannot be mistaken as an item from the list
answer
sentinel
question
To open a file for writing, you use the following class
answer
PrintWriter
question
To open a file for reading, you use the following class
answer
File and Scanner
question
When a program is finished using a file, it should do this
answer
close the file
question
This class allows you to us the print and println methods to write data to a file
answer
PrintWriter
question
This class allows you to read a line from a file
answer
Scanner
question
The while loop is a pretest loop
answer
true
question
The do-while loop is a pretest loop
answer
false
question
The for loop is a posttest loop
answer
false
question
It is not necessary to initialize accumulator variables
answer
false
question
One limitation of the for loop is that only one variable may be initialized in the initialization expression
answer
false
question
A variable may be defined in the initialization expression of the for loop
answer
true
question
In a nested loop, the inner loop goes through all of its iterations for every iteration of the outer loop
answer
true
question
To calculate the total number of iterations of a nested loop, add the number of iterations of all the loops
answer
false