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;
41 Cards in this Set
- Front
- Back
Identifiers can only begin with
|
letter, underscore, currency character
|
|
Legal identifiers after the first character
|
letter, underscore, currency character, numbers
|
|
Identifiers max length
|
meh... infinite I guess.
|
|
True / False: A source code file can have any number of public classes, but only 1 default access class.
|
False. 1 public class per java file. Many default access allowed.
|
|
JavaBean method rules must
|
use camelCase naming and naming conventions:
setVarName getVarName isBooleanName addSomeListener removeSomeListener |
|
Must a java file name must always match the public class name?
|
Yes, unless there is no public class (then the file name can be whatever).
|
|
True/False: A file can have any number of public classes, but must only have 1 default or private class.
|
False. Can have many default, 1 public (optionally), and 0 private classes.
|
|
In reference to package and/or import statements, where can comments go?
|
Anywhere. //even here!
|
|
True / False: The import statements are the first non-comment code in a java file
|
Depends. True only if there is no package statement. Otherwise imports are the first non-comment code after the package statement.
|
|
How many import and package statements are allowed in a java file?
|
import = 0 to many
package = 0 to 1 |
|
True / False: Files with no public classes have no naming restrictions.
|
True. Only match file name to public class. If no public class then name it whatever!
|
|
Name all access modifiers.
|
public, private, protected.
|
|
Name all access (visibility) levels.
|
default, public, private, protected
|
|
What visibility can a class have (pretend inner classes don't exist).
|
default and public
|
|
Where is a default level class viewable?
|
It is accessible from any other class in the package.
|
|
Class access (visibility) revolves around whether code in one class can:
|
Create an instance of another class.
Extend (subclass) another class. Access members (methods and variables) of another class. |
|
Name the legal non-access modifier for a class
|
final, abstract, strictfp
|
|
True / False:
public final abstract class People {} Compiles just fine. |
WRONG! final and abstract... always illegal and preposterous when defining the same thing.
|
|
What does a class marked final indicate?
|
It can't be extended (subclassed).
|
|
True / False: An abstract class can never be instantiated.
|
True. Only a concrete subclass of abstract class can be instantiated.
|
|
True / False: All classes that extend an abstract class must implement the abstract methods.
|
False. The first concrete class must implement all the abstract methods up the whole inheritance hierarchy.
|
|
Interfaces... briefly describe what they are.
|
Contracts for WHAT a class can do. They say nothing about exactly HOW the class must do it.
|
|
What classes can implement interfaces?
|
Any class, from any inheritance tree.
|
|
How many abstract methods is a non-abstract class allowed to have?
|
0. If a class has any abstract methods it must be an abstract class.
|
|
How many non-abstract methods can an abstract class have?
|
An abstract class can have any number of abstract
or non-abstract methods. |
|
How many non-abstract methods can an interface have?
|
0. All methods are abstract.
|
|
Which is correct?
1. abstract interface Loveable { } 2. interface Loveable { } |
Both. Interfaces are always abstract, so it can be implicit (thus untyped as in 2).
|
|
How do access levels for interface, abstract, and regular classes differ?
|
They don't. All have default or public visibility,
|
|
Interface variables are implicitly..
|
public, static and final (really considered constants)
|
|
Interface methods are implicitly (and can be marked) with both of these modifiers
|
public abstract
|
|
True / False: Interface constants can be marked with any combination of the words public static final, but none are required.
|
True. Weird, right? These modifiers are in effect even if not present.
|
|
A legal non-abstract implementing class must:
|
Provide concrete implementations of methods.
Follow legal override rules for each method. Must not declare any new (or broader) checked exceptions. |
|
True / False: Interfaces can implement any number of other interfaces.
|
False. Interfaces can extend any number of interfaces.
|
|
True / False. Interfaces can extend a classes.
|
False. They can only extend interfaces.
|
|
What are class "members" ?
|
Methods themselves and instance variables. Basically all non-local variables in a class.
|
|
Name all possible member access levels
|
private, public, protected, default
|
|
What type of visibility trumps member visibility?
|
Class visibility. A member can be public, but the class may be default. Classes in other packages cannot see those methods marked public (because they can't see the class they're in).
|
|
True / False: Public members can be accessed by all other classes, even in other packages.
|
Um... True? Assuming the class is public. If the class is not visible then the public members are not.
|
|
'this' always refers to:
|
the currently executing object.
|
|
Private methods are only accessible to:
|
code in the same class.
|
|
True / False: Private methods are not inheritable, but subclasses can legally have a method with the same exact signature.
|
True. Since the subclass can't see the superclass method, it is legal to redefine. This is a type of "hiding".
|