1.Declarations and Access Control Flashcards
Identifiers can begin with…
a letter, an underscore, or a currency character
After the first character…
identifiers can also include digits
Identifier length can be…
Identifiers can be of any length
You can compile and execute Java programs using the command-line programs…
java and javac. Both programs support a variety of
command-line options.
The only versions of main() methods with special powers are those
versions with method signatures equivalent to…
public static void main(String[] args)
can main be overloaded?
Yes
what does an import statement is good for?
only job is to save keystrokes
why do we use asterisk (*) in imports?
to search through the contents of a single
package
what is the syntax for static imports?
import static….
how many public classes can a source file have?
only one
If the source file contains a public class, what can be the class names?
the filename must match the public class name
How many package statements can a file have?
Only one
Where is the correct place for package statement
the first line in a source file
Where is the correct place for import statement
after the package and before the class declaration. If there is no package statement, import statements must be the first (noncomment) statements in the source file.
how the package and import statements apply to classes in a file
to all classes in the file
how many nonpublic classes can a file have?
more than one
How can we name nonpublic classes?
no public classes have no naming restrictions
What are class access modifiers?
public, protected, and private
How many access levels are there?
public, protected, default, and private
Which accesses a class can have?
public or default access
A class with default access can be seen..
only by classes within the same
package.
A class with public access can be seen by…
all classes from all packages.
Class visibility revolves around whether code in one class can…
❑ Create an instance of another class
❑ Extend (or subclass) another class
❑ Access methods and variables of another class
Nonaccess modifiers for classes are…
final, abstract, or strictfp