Declarations and Access Control Flashcards
* Declare Classes & Interfaces. * Develop Interfaces & Abstract Classes. * Use Primitives, Arrays, Enums, & Legal Identifiers. * Use Static Methods, JavaBeans Naming and Var-Args.
Identifiers can begin with what characters?
A letter, an underscore, or a currency character.
After the first character, identifiers can also include…?
digits.
How long can identifiers be made?
Any length.
JavaBeans methods must be named using what kind of format?
camelCase
Depending on the method’s purpose, JavaBeans methods must start with what?
set, get, is, add, or remove
A ________ code file can have only one public class.
source
(True/False) If the source file contains a public class, the filename cannot match the public class name.
false (it must match)
A file can have only one _______ statement, but multiple imports.
package
The package statement (if any) must be the ________ (non-comment) line in a source file.
first
The ________ statements (if any) must come after the package and before the class declaration.
import
If there is no package statement, what type of statements must be the first (non-comment) statements in the source file?
import
(True/False) Package and import statements apply to some of the classes in the file?
false (applies to all the classes)
Can a file have more than one nonpublic class?
yes
Do files with no public classes have naming restrictions?
no
What are the three access modifiers?
public, protected, and private
What are the four levels of access?
public, protected, default, and private
Classes can have only public or ______ access.
default
(True/False) A class with default access can be seen only by classes within the same package.
true
A class with ______ _______ can be seen by all classes from all packages.
public access
Class visibility revolves around whether code in one class can ____an instance of another class, _____ another class, and ____methods and variables of another class.
create, extend or subclass, access
Classes can also be modified with ______, abstract, or ________.
final…strictfp
Can a class be both final and abstract?
no
What type of class cannot be subclassed?
final
What type of class cannot be instantiated?
abstract