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;
69 Cards in this Set
- Front
- Back
start with: a letter, $, underscore
|
|
|
What are JavaBeans?
|
Java classes that have properties.
|
|
JavaBeans methods
|
camelCase and prefixed with set, get, is, add, remove
|
|
JavaBeans properties
|
private instance variables accessed with getter and setters
|
|
JavaBeans Events
|
The JavaBean spec supports events, which allow components to notify each other when something happens.
|
|
JavaBeans: add a listener
|
prefix add, followed by the listener type. Ex: addActionListener()
|
|
JavaBeans: remove a listener
|
prefix remove, followed by the listener type. Ex: removeActionListener()
|
|
JavaBeans: Listener method names suffix?
|
must end with the word "Listener"
|
|
How many public classes per source code file?
|
1
|
|
What is necessary of public class name?
|
Must match the name of the source file
|
|
The package statement must be the first line in the source code file, before any import statements that may be present.
|
|
|
Files with no public classes can have a name that does not match any of the classes in the file.
|
|
|
class access levels (4P)
|
public, protected, package (default), private
|
|
class access modifiers (3P)
|
public, protected, private
|
|
class non-access modifiers (AFN3STV)
|
abstract, final, native, static, synchronized, strictfp, transient, volatile
|
|
** Class Access
|
|
|
How to access a class?
|
Create an instance of class B. Extend class B. Access methods and variables.
|
|
class package (default) access
|
No modifiers. Can be seen only by classes within the same package.
|
|
class public access
|
All classes have access to a public class.
|
|
class: strictfp
|
A class or a method (never a variable) will conform to the IEEE 754 standard rules for floating points.
|
|
class: final classes
|
the class can't be subclassed
|
|
abstract classes
|
can never be instantiated, only extended
|
|
Can you mark a class as both abstract and final?
|
No
|
|
interface description
|
A contract for what a class can do, without saying anything about how the class will do it.
|
|
interface access
|
implicitly abstract, can be default or public
|
|
interface method access
|
implicitly public and abstract, not static, final, strictfp or native
|
|
interface variable access
|
public static final - i.e. constants - don't have to be declared
|
|
interface can extend other interfaces?
|
Yes and only other interfaces
|
|
interface can be used polymorphically?
|
Yes
|
|
class member access modifiers
|
public, protected, package (default), public
|
|
class member: two different access issues
|
access and inheritance
|
|
class member is public
|
all other classes can access the member
|
|
class member is private
|
can only be accessed in the class it was declared
|
|
class member is default (package)
|
can only be accessed in the same package
|
|
class member is protected
|
can only be accessed through inheritance or in the same package
|
|
class: protected member access from other instance in same class
|
The protected member becomes private.
|
|
class member: Can access modifiers be applied to local variables?
|
No. (the only modifier that can be used is final)
|
|
class member: final methods
|
prevents a method from being overridden in a subclass
|
|
class member: final arguments
|
can't be modified
|
|
class member: abstract methods
|
not implemented, without method body, makes the class abstract
|
|
class member: The first concrete subclass of an abstract class must implement all abstract methods of the superclass
|
|
|
class member: abstract cannot be combined with
|
private, final or static
|
|
synchronized methods
|
A method can be accessed by only one thread at a time. Applies only to methods.
|
|
class member: the synchronized modifier can be matched with
|
any of the four access control levels
|
|
class member: native methods
|
Indicates that a method is implemented in platform-dependent code. Applies only to methods. Note that a native method's body must be a semicolon (like abstract methods), indicating that the implementation is omitted.
|
|
strictfp methods
|
Strictfp forces floating points to adhere to the IEEE 754 standard
|
|
Methods with Variable Argument Lists (var-args)
|
Must be the last and only parameter. Syntax <type>... <id>.
|
|
class member: Non-allowed modifiers
|
abstract, final and static
|
|
class member: Two types of variables
|
primitives and reference variables
|
|
Primitives 8 types
|
char boolean INTEGER(byte short int long) FLOAT(float double) : integers and floats are signed
|
|
integer sizes and ranges
|
8,16,32,64 : -2^(n-1) - 2^(n-1)-1
|
|
float sizes and ranges
|
32,64 : n/a
|
|
char size
|
16
|
|
primitives and refs 4 declarations
|
static instance parameters local
|
|
instance variables access levels
|
4P
|
|
instance variables non-access modifiers (FTV)
|
final, transient, volatile
|
|
Local variables are declared
|
in a method. They are on the stack.
|
|
local variables non-access modifiers (F)
|
final
|
|
Local variables don't get default values
|
|
|
array declarations
|
On the heap. <type>[] <identifier> or <type> <identifier> []
|
|
int[5] score
|
Good or Bad?
|
|
final variables
|
Makes it impossible to reinitialize that variable once it has been initialized with an explicit value. There are no final objects, only final references
|
|
transient variables
|
Don't serialize.
|
|
volatile variables
|
Always check the master copy of the variable. Applies only to instance variables.
|
|
static variables and methods
|
Can also be applied to class nested class, initialization blocks
|
|
** Declaring Enums
|
enum <TypeName> {CONST1, CONST2, } (semicolon at the end is optional). Can be declared inside or outside of classes, but not in methods.
|
|
enums access modifiers
|
public or package
|
|
enums inside class
|
Enclosing class name required in dereferencing.
|
|
enums: constant specific class body
|
A method specific to a constant that overrides a method defined in the enum.
|