Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
52 Cards in this Set
- Front
- Back
Call the addItem method of the client object. What must be included in the statement?
|
client.addItem(); the parenthesis must be included
|
|
If you want to format a string before output, what method of the System could you use?
|
System.out.format();
|
|
What could a method return? (3)
|
1) reference to an obj; 2) a primitive; 3) null;
|
|
If a method returns an object, you can call the methods of that returned object in the ________ ________, using ________ method calls.
|
same statement; nested
|
|
Why would you use a class method?
|
creating a general utility function which might need to be independent of object instances, but makes sense to include in the class
|
|
What is an object reference?
|
an address indicating where an object is stored
|
|
What are primitive type wrappers?
|
classes, whos objects can contain primitive values
|
|
What is Autoboxing?
|
automatic conversion of primitives to their respective object wrappers and vice versa
|
|
What is unboxing?
|
conversion of primitive type object wrappers to their primitive values
|
|
What is Casting?
|
Converting one type to another
|
|
How does the == operator behave with objects?
|
it determine whether both sides of the operator refer to the same object
|
|
What method of a String object, could you call to perform a comparison?
|
String.equals()
|
|
How do you define a constant?
|
use the keyword final before the declaration i.e. final string name = Tom;
|
|
What does System.out.println(x) do
|
Prints to the system console the value of x followed by a line break
|
|
What does System.out.print(x) do
|
Prints to the system console, the value of x without a line break
|
|
List three kinds of comments in Java
|
single line (//) with no ending tag, multi-line (/*) with an ending tag (*/) and Javadoc (/**) with an ending tag (*/)
|
|
What is special about comments that start with (/**) and ends with (*/)
|
javadoc comments; are designed to be read by utilities which can create external documentation
|
|
What is a literal?
|
any number, text, or other value
|
|
In the following expression, pennyTotal = pennyTotal + 4L; What does the L after 4L indicate?
|
It formats the number 4 (a literal value) as the data type long
|
|
How would you use a literal with octal numbering? for the octal number 777
|
Add a zero in front of the number, 0777
|
|
How would you use a literal with hexidecimal numbers? for the number FF?
|
Prepend 0x (zero-x), 0xFF
|
|
How would you use a literal with binary numbers? for the number 11111111?
|
Prepend with 0b (zero-b), 0b11111111
|
|
All floating-point literals are considered to be of the type _________. How would you assign a literal value to a float var? for 3.1415927?
|
double, the literal followed by an F, like this: 3.1415927F
|
|
How can you use exponents in floating-point literals? for the number 12 to the power of 22?
|
use e or E to denote the exponent, 12e22 or 12E22
|
|
You can not use commas in large numbers like 3,500,000 as a literal. What else can you do to ensure readability?
|
In Java 7 and higher, use underscores like 3_500_000
|
|
T/F? Only the literals 1 or 0 may be assigned to a boolean in Java.
|
False, you can only assign the literals true or false to boolean in Java
|
|
How are character (char) literals expressed?
|
using single quotes
|
|
Identify the character escape code: \n
|
New line
|
|
Identify the character escape code: \t
|
Tab
|
|
Identify the character escape code: \b
|
Backspace
|
|
Identify the character escape code: \r
|
Carriage return
|
|
Identify the character escape code: \f
|
Formfeed
|
|
Identify the character escape code: \\
|
Backslash (the 1st backslash denotes an escape character)
|
|
To use a single or double quote in a literal, what must you do?
|
Prefix it with an escape code - backslash \
|
|
Most mathematical operators can be safely used on integers, except ...
|
division. the result may end up being a floating-point number and that can not be handled by an int
|
|
What is the safest way to determine data types for numbers to be used in calculations?
|
by examining the type youre trying to end up with. using incompatible types will result in unpredictable values
|
|
Increment var x
|
x++;
|
|
Decrement var x
|
x--;
|
|
In the following expression, where y=1; x = y++; What value is x assigned?
|
1
|
|
In the following expression, where y=1; x = ++y; What value is x assigned?
|
2
|
|
What is the difference between prefix and postfix operators, when assigning to a variable (++x x--)
|
prefix (++x) performs the operation, then makes the assignment; postfix (x++) performs assignment, then performs the operation
|
|
The difference between & and &&
|
AND operator; 1) &, the expression on both sides of the operator are evaluated; 2) &&, if the left expression is false, the right expression is never evaluated
|
|
The difference between | and ||
|
OR operator; 1) |, both sides of the operator are evaluated; 2) ||, if the left side is true, the right side is never evaluated
|
|
What is the ^ comparison operator?
|
XOR, if left or right side of operator are opposites, expression is true. If both are same, expression is false.
|
|
What is special about the String data type in Java?
|
1) allows direct assignment of data; 2) treated as a class not a data type; 3) creates an instance of the class when assigned to
|
|
Are primitive data types in Java, also objects?
|
No
|
|
Use the ___ keyword to create an instance of a class. Provide an example.
|
new; Object objectName = new Object();
|
|
What are the default delimiters in StringTokenizer?
|
spaces, tabs, newlines, cr or ff
|
|
At a high level, what happens when you create a new instance?
|
1) memory is allocated for it; 2) constructor is called
|
|
What is a constructor?
|
special method that initializes a new object
|
|
When a class has multiple constructors, how are they differentiated from each other?
|
number and type of arguments (also called its signature)
|
|
What is Java garbage collection?
|
Java can determine whether an object has any live references to it. It periodically checks for unused objects, disposes of them and reclaims the memory.
|