• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/83

Click to flip

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;

83 Cards in this Set

  • Front
  • Back
abstract, boolean, break, byte, case, catch, char, class, const, continue, default, do, double, else, extends, final, finally, float, for, goto, if, implements, import, instanceof, int, interface, long, native, new, package, private, protected, public, return, short, static, strictfp, super, switch, synchronized, this, throw, throws, transient, try, void, volatile, while, assert, enum
Keywords
must start with letter, currency char, or connecting char such as underscore
after 1st char, may contain any combination of letters, currency, connecting, or numbers
no limit to number of chars
no Java keywords
case-sensitive
int _a;
int $c;
int _____2_w;
Legal Identifiers
int :b;
int -d;
int e#;
int .f;
int 7g;
Illegal Identifiers
one public class per source code file
comments can be anywhere
name of file must match the name of the public class
package name must be the first line before imports
imports must go between package and class declaration
imports and package statements apply to all classes in a file
a file can have more than one nonpublic class
files with no public classes can have a name that doesn't match any of the classes in the file
Source File Declaration Rules
class A can:
create instance of B
extend B
access certain methods and variables within B, depending
Class Access "class A has access to class B"
no modifier preceding
package-level access
Default Access
all classes from all packages have access
Public Access
final, abstract, strictfp
Nonaccess
class can't be subclassed
many classes in Java core library
Final Classes
can never be instantiated
sole purpose is to be extended
Abstract Classes
a contract for what a class can do without saying anything about how the class will do it
like a 100% abstract superclass that defines the methods a subclass must support, but not how they must be supported
names should be adjectives
can only have abstract methods
all methods are implicitly public and abstract
all variables must be public, static, and final - i.e., constants
methods must not be static
methods cannot be final, strictfp, or native
can extend one of more others like it
cannot extend anything but others like it
cannot implement another
types can be used polymorphically
Interface
public abstract interface Rollable {}
Legal Interface Declaration (abstract modifier is redundant)
public and abstract identifiers on interface methods is
redundant since all interface methods are implicitly public and abstract
just as interface methods are always public and abstract whether you say so or not, any variable defined in an interface must be - and implicitly is -
a public constant
public, protected, default, private
Access Modifiers
all classes, regardless of package can access
public method or public variable member
can't be accessed by code in any class other than the class in which the ___ ___ was declared
private member
when a member is declared private, a subclass can / can't inherit it?
a subclass can't inherit it
can a private method be overridden by a sublass?
no - the subclass cannot inherit a private method, so it is simply declaring a new method with the same name
what is the one critical difference between protected and default access control?
a default member may be accessed only if the class accessing the member belongs to the same package, whereas a protected member can be accessed (through inheritance) by a subclass even if the subclass is in a different package
the subclass can see the protected member only through ___
inheritance
can access modifiers be applied to local variables
NO - there is never a case where an access modifier can be applied to a local variable
the ___ keyword prevents a method from being overridden in a subclass and is often used to enforce the API functionality
final
a ___ argument must keep the same value it had when it was passed into the method
final
a method that has been declared (as ___) but not implemented
abstract
an abstract method ends with a ___ and has no ___ ___
semicolon, curly braces
it is illegal to have even a single abstract method in a ___ ___
non-abstract class
the first concrete subclass of an abstract class must
implement all abstract methods of the superclass
a method can never, ever, ever be marked as both ___ and ___, or both ___ and ___
abstract and final
abstract and private
the ___ and ___ modifiers are virtually opposites
abstract and final
the abstract modifier can never be combined with the ___ modifier
static
the ___ keyword indicates that a method can be accessed by only one thread at a time
synchronized
the synchronized modifier can be applied only to ___ - not variables, not classes, just ___
methods
the synchronized modifier can be matched with any of the four ___ ___
access modifiers (three access modifier keywords)
indicates that a method is implemented in platform-dependent code, often in C
native
can be applied only to methods
forces floating points to adhere to the IEEE 754 standard
can modify a class or method but never a variable
strictfp
when you declare it, you must specify the type of argument(s) this parameter of your method can receive (this can be a primitive type or an object type)
var-arg type
to declare a method follow the type with an ellipsis (...), a space, and then the name of the array that will hold the parameters received
basic syntax of var-arg type
the var-arg must be the ___ parameter in the method's signature, and you can have only ___ var-arg in a method
last, one
void doStuff(int... x) {} // expects 0 to many ints as parameters
void doStuff2(char c, int... x) {} // expects first a char, then 0 to many ints
void doStuff3(Animal... animal) {} // 0 to many Animals
legal var-args
void doStuff4(int x...) {}
void doStuff5(int... x, char... y) {}
void doStuff6(String... s, byte b) {}
illegal var-args
a ___ can't ever, ever, ever have a return type
constructor
can have all the normal access mods
must have the same name as the class they are in
can't be marked static
can't be marked final or abstract
can't be overridden
constructor declarations
what are the two types of variables in Java?
primitives, reference variables
can be one of 8 types: char, boolean, byte, short, int, long, double, float
once declared, type cannot change - in most cases its value can change
primitives
used to refer to (or access) an object. declared to be of a specific type and that type can never be changed. can be used to refer to any object of the declared type, or of a subtype of the declared type (a compatible type)
reference variables
defined inside the class but outside any methods. are only initialized when the class is instantiated. the fields that belong to each unique object
instance variables
sequence from small to big for integer types
byte, short, int, long
which is bigger double or float?
double
how many bits for a double?
64
how many bits for a float?
32
what is the bit depth of a boolean?
it's virtual machine dependent
can use any of the 4 access levels (which means they can be marked with any of the three access modifiers)
can be final
can be transient
cannot be abstract
cannot be synchronized
cannot be strictfp
cannot be native
cannot be static, because then they'd become class variables
instance variables
modifiers on local variables
final
modifiers on non-local variables
final, public, protected, private, static, transient, volatile
modifiers on methods
final, public, protected, private, static, abstract, synchronized, strictfp, native
variables declared within a method. destroyed when the method ends. are always on the stack, not the heap
local variables
there is no such thing as a stack ___, only a stack ___
object, variable
objects that store multiple variables of the same type or variables that are all subclasses of the same type
can hold either primitives or object references
arrays
there is no such thing as a ___ array, but you can make an array of ___
primitive, primitives
are declared by stating the type of elements it will hold (object or primitive) followed by square brackets to either side of the indentifier
int[] key;
int key [];
array
it is never legal to include the ___ of the array in your declaration
size
declaring with keyword ___ makes it impossible to reinitialize a variable when it has been initialized with an explicit value
final
a reference variable marked ___ can't ever be reassigned to a different object
final
there are no final ___ only final ___
object, references
if you mark an instance variable as ___, you're telling the JVM to ignore this variable when you attempt to serialize the object containing it
transient
tells the JVM that a thread accessing the variable must always reconcile its own private copy of the variable with the master copy in memory
volatile
used to create variables and methods that will exist independently of any instances created for the class
exist before you ever make a new instance of the class, and there will be only one copy of the member regardless of the number of instances of that class
all instances of a given class, share the same value for any given ___ variable
static
things you can mark as static
methods, variables, nested class, initialization blocks
things you can not mark as static
constructors, non-nested classes, interfaces, method local inner classes, local variables
can be declared as their own separate class or as a class member, however they must not be declared within a method
enum
the semicolon is ___ at the end of the enum declaration
optional
it is important to remember that ___ are not String or ints. think of them as a kind of class
enums
specifies a list of constant values that can be assigned to a particular type
enum
NOT a String of an int; a ___'s constant's type is the ___ type. For example, WINTER, SPRING, SUMMER, FALL are of the ___ type Season
enum
an enum can be declared ___ or ___ but not ___
outside a class, inside a class, in a method
an enum declared ___ a class must NOT be marked static, final, abstract, protected, or private
outside
enums can contain
constructors, methods, variables, constant class bodies
enum constants can ___ using the syntax BIG(8) where the int literal 8 is passed to the enum constructor
send arguments to the enum constructor
enum constructors ___ have arguments and ___ be overloaded
can, can
enum constructors can ___ be invoked directly in code.
NEVER, they are always called automatically when an enum is initialized
three access modifiers
public, protected, private
four access levels
public, protected, private, default