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;
106 Cards in this Set
- Front
- Back
local variables live on the ___
|
stack
|
|
objects and their instance variables live on the ___
|
heap
|
|
integer literals can be ___, ___, or ___
|
decimal, octal (e.g. 013), or hexadecimal (e.g. 0x3d)
|
|
literals for longs end in _ or _
|
L, l
|
|
float literals end in _, or _
|
F, f
|
|
double literals end in a ___ or _ or _
|
digit, D, d
|
|
the boolean literals are ___ and ___
|
true, false
|
|
literals for ___ are a single character inside single quotes: 'd'
|
char
|
|
___ refers to the lifetime of a variable
|
scope
|
|
static variables live basically as long as their ___ lives
|
class
|
|
instance variables live as long as their ___ lives
|
object
|
|
local variables live as long as their ___
|
variable is on the stack; however, if their method invokes another method, they are temporarily unavailable
|
|
block variables (e.g., in a for or an if) live until ___
|
the block completes
|
|
literal integers are implicitly ___
|
ints
|
|
integer expressions always result in an ___-sized result, never smaller
|
int
|
|
local variables live on the ___
|
stack
|
|
objects and their instance variables live on the ___
|
heap
|
|
integer literals can be ___, ___, or ___
|
decimal, octal (e.g. 013), or hexadecimal (e.g. 0x3d)
|
|
literals for longs end in _ or _
|
L, l
|
|
float literals end in _, or _
|
F, f
|
|
double literals end in a ___ or _ or _
|
digit, D, d
|
|
the boolean literals are ___ and ___
|
true, false
|
|
literals for ___ are a single character inside single quotes: 'd'
|
char
|
|
___ refers to the lifetime of a variable
|
scope
|
|
static variables live basically as long as their ___ lives
|
class
|
|
instance variables live as long as their ___ lives
|
object
|
|
local variables live as long as their ___
|
variable is on the stack; however, if their method invokes another method, they are temporarily unavailable
|
|
block variables (e.g., in a for or an if) live until ___
|
the block completes
|
|
literal integers are implicitly ___
|
ints
|
|
integer expressions always result in an ___-sized result, never smaller
|
int
|
|
floating point numbers are implicitly ___
|
doubles (64-bit)
|
|
narrowing a primitive truncates the ___ ___ bits
|
high order
|
|
compound assignments (e.g. +=) perform an ___ cast
|
automatic
|
|
a reference variable holds the bits that are used to ___
|
refer to an object
|
|
reference variables can refer to subclasses of the declared type but not to ___
|
superclasses
|
|
when creating a new object, e.g., Button b = new Button();, three things happen
|
make a reference variable named b of type Button
create a new Button object assign the Button object to the reference variable b |
|
when an array of objects is instantiated, objects within the array are not instantiated automatically, but all the references get the default value of ___
|
null
|
|
when an array of primitives is instantiated, elements get ___ ___
|
default values
|
|
instance variables are always initialized with ___
|
a default value
|
|
___ variables are never given a default value. if you attempt to use one before initializing it, you'll get a compiler error
|
local/automatic/method
|
|
methods can take ___ and/or ___ ___ as arguments
|
primitives, object references
|
|
method arguments are always ___
|
copies
|
|
a primitive argument is an ___ ___ of the original primitive
|
unattached copy
|
|
a reference argument is ___
|
a copy of a reference to the original object
|
|
___ occurs when two variables with different scopes share the same name. this leads to hard-to-find bugs and hard-to-answer exam questions
|
shadowing
|
|
arrays can hold primitives or objects, but the array itself is always an ___
|
object
|
|
when you declare an array, the brackets ___
|
can be left or right of the name
|
|
it is never legal to include the ___ of an array in the declaration
|
size
|
|
you must include the size of an array when you construct it (using new) unless you ___
|
are creating an anonymous array
|
|
elements in an array of objects are ___, although primitive array elements are given default values
|
not automatically created
|
|
you'll get a ___ if you try to use an array element in an object array, if that element does not refer to a real object
|
NullPointerException
|
|
arrays are indexed beginning with ___
|
zero
|
|
an ___ occurs if you use a bad index value
|
ArrayIndexOutOfBoundsException
|
|
arrays have a length variable whose value is ___
|
the number of array elements
|
|
the last index you can access is always ___ of the array
|
one less than the length
|
|
multidimensional arrays are just ___
|
arrays of arrays
|
|
the dimensions in a multidimensional array can/cannot have different lengths
|
can
|
|
an array of ___ can accept any value that can be promoted implicitly to the array's declared type:. e.g., a byte variable can go in an int array
|
primitives
|
|
an array of objects can hold any object that passes the ___ test for the declared type of the array. for example, if Horse extends Animal, then a Horse object can go into an Animal array
|
IS-A (or instanceof)
|
|
if you assign an array to a previously declared array reference, the array you're assigning ___
|
must be the same dimension as the reference you're assigning it to.
|
|
you can assign an array of one type to a previously declared array reference of one of its ___. for example, a Honda array can be assigned to an array declared as type Car (assuming Honda extends Car)
|
supertypes
|
|
static initialization blocks run ___, when the class is first loaded
|
once
|
|
instance initialization blocks run ___. they run after all super-constructors and before the constructor's code has run
|
every time a new instance is created
|
|
if multiple init blocks exist in a class, ___
|
they follow the other rules of init blocks, AND they run in the order in which they appear in the source file
|
|
the wrapper classes correlate to the ___ types
|
primitive
|
|
wrappers have two main functions
|
to wrap primitives so that they can be handled like objects
to provide utility methods for primitives (usually conversions) |
|
the three most important method families are
|
xxxValue() takes no arguments, returns primitive
parseXxx() takes String, returns primitive, throws NFE valueOf() takes String, returns wrapped object, throws NFE |
|
wrapper constructors can take a String or a primitive, except for ___
|
Character, which can only take a char
|
|
radix refers to ___
|
bases (typically) other than 10; octal is radix = 8, hex = 16
|
|
___ allows you to convert primitives to wrappers or to convert wrappers to primitives automatically
|
boxing
|
|
using ___ with wrappers created through autoboxing is tricky
|
==, those with small values (typically lower than 127), will be ==, larger values will not be ==
|
|
___ ___ uses the "smallest" method argument possible
|
primitive widening
|
|
used individually, boxing and var-args are compatible with ___
|
overloading
|
|
you ___ widen from one wrapper type to another
|
CANNOT, IS-A fails
|
|
you ___ widen and then box
|
CANNOT, an int can't become a long
|
|
you can assign an array of one type to a previously declared array reference of one of its ___. for example, a Honda array can be assigned to an array declared as type Car (assuming Honda extends Car)
|
supertypes
|
|
static initialization blocks run ___, when the class is first loaded
|
once
|
|
instance initialization blocks run ___. they run after all super-constructors and before the constructor's code has run
|
every time a new instance is created
|
|
if multiple init blocks exist in a class, ___
|
they follow the other rules of init blocks, AND they run in the order in which they appear in the source file
|
|
the wrapper classes correlate to the ___ types
|
primitive
|
|
wrappers have two main functions
|
to wrap primitives so that they can be handled like objects
to provide utility methods for primitives (usually conversions) |
|
the three most important method families are
|
xxxValue() takes no arguments, returns primitive
parseXxx() takes String, returns primitive, throws NFE valueOf() takes String, returns wrapped object, throws NFE |
|
wrapper constructors can take a String or a primitive, except for ___
|
Character, which can only take a char
|
|
radix refers to ___
|
bases (typically) other than 10; octal is radix = 8, hex = 16
|
|
___ allows you to convert primitives to wrappers or to convert wrappers to primitives automatically
|
boxing
|
|
using ___ with wrappers created through autoboxing is tricky
|
==, those with small values (typically lower than 127), will be ==, larger values will not be ==
|
|
___ ___ uses the "smallest" method argument possible
|
primitive widening
|
|
used individually, boxing and var-args are compatible with ___
|
overloading
|
|
you ___ widen from one wrapper type to another
|
CANNOT, IS-A fails
|
|
you ___ widen and then box
|
CANNOT, an int can't become a Long
|
|
you ___ box and then widen
|
can, (an int can become an Object, via an Integer)
|
|
you can combine ___ with either widening or boxing
|
var-args
|
|
in Java, ___ provides automated memory management
|
garbage collection (GC)
|
|
the purpose of GC is ___
|
to delete objects that can't be reached
|
|
___ ___ ___ decides when to run the GC
|
only the JVM, you can only suggest it
|
|
you can't know the ___ ___ for sure
|
GC algorithm
|
|
objects must be considered ___ before they can be garbage collected
|
eligible
|
|
an object is ___ when no live thread can reach it
|
eligible
|
|
to reach an object, you must have a ___
|
live, reachable reference to that object
|
|
Java applications can/can't run out of memory
|
can
|
|
islands of objects can/can't be GCed
|
can, even though they refer to each other
|
|
request garbage collection with ___
|
System.gc(); (recommended)
|
|
class ___ has a finalize() method
|
Object
|
|
the ___ method is guaranteed to run once and only once before the garbage collector deletes an object
|
finalize()
|
|
the garbage collector makes no guarantees
|
finalize() may never run
|
|
you can make an object ineligible for GC from within ___
|
finalize()
|