1. Declarations & Access Control Flashcards
Does a supercalss know anything about the subclasses that inherit from it?
No
Is a subclass free to override instance variables and methods define in a superclass?
Yes
Does an interface method have to be implemented?
Yes
Can an _ be used at the beginning of an identifier?
Yes
Is this a legal identifier:
:b
No, identifiers cannot start with a colon
Is this a legal identifier:
-d
No, identifiers cannot begin with a -
Can identifiers begin with a number?
No
Can # be part of an identifier?
No
Where can a public method be accessed from?
Anywhere
Where can a private method be accessed from?
Only within that class in which it is declared.
How many public classes per source file can there be?
1
What must come first, package statements or import statements?
Package statements
How many non-public classes can a source file have?
Any number
What is the syntax for static imports:
import static…
static import…
import static…
Can you use an import statement to search through the java API such as ‘import java.*’
No, this is legal but it will NOT search across packages
What are the 3 access modifiers?
Public
Private
Protected
What are the three nonaccess modifiers you need to know for the OCA exam
strictfp
final
abstract
What is the default access modifier that is not typed?
default
Can you have private classes?
No
Can you have protected classes?
No
What is the visibility of a class with default access?
Within same package only
If a class is public, yet in a different package, do you still need to have an import statement to gain access to that class.
Yes
Should a class ever be marked as both final and abstract?
No
What is strictfp
a non-access modifier that can modifiy a method or a class