Braineos
DiscoverChallenges
Sign in
← Back to decks
Sign in to save your progress, vote, and build your own decks.Sign in

SCJP 6 declarations and access control

54 cards·by megsmitley
scjpcomputingjava
Study this deck
Begin an identifier with
a letter underscore or currency char
Excluding the first char identifiers can include
digits
The length of an identifier may be
of any length
JavaBean methods are named in what case style?
camelCase
JavaBeans methods must start with
set, get, is, add, or remove
How many public classes per file
one
Where a file contains a public class the filename
must be the same as the class name
Number of package statements per file
one
Number of import statements per file
one or more
Package statements are included where in a file
the first uncommented line
Import statements are included where in a file
after the package statement and before class declaration
What classes do package and import statements effect
all classes in a file
Naming restrictions on files without a public class?
none
Name the three access modifiers.
public,private and protected
Name the four access levels.
public, protected, default and private
Classes can have what types of access?
public or default
Classes with default access can be seen
only by classes within the same package
Classes with public access can be seen
by all classes in all packages
Class visibility relates to what three concepts re. code in a class can:
create an instance of class, extend a class; access methods and vars
Interfaces implicitly denote what modifier?
abstract
Interface methods can only be
abstract
Interface constants implicitly denote what access?
public static final
2 rules for exceptions in (non abstract) implementing classes
no new checked exceptions and no broader checked exceptions
Rule for runtime exceptions in (non abstract) implementing classes
can be declared on any interface method
Classes can extend ___ classes
only one
Classes can implement ___ interfaces
one or more
Interfaces can extend ___
one or more interfaces
Interfaces cannot extend ___ or ___
a class, implement a class or interface
'Members' refers to
methods and instance variables
Name access levels applicable to members
public, private, protected and default
Name 2 means of member access
code in a class accesses member of another class and a subclass inherits superclass members
If you can't access the class
you can't access the members
public members are accessible to
all classes in all packages
public superclass members
are always inherited
I can use the dot operator to access
members of the current class
private members are accessible to
only code in the current class
private superclass members
are never inherited
default members are accessible to
only classes in the same package
protected members are accessible to
classes in the same package and subclasses in any package
Subclasses out side a protected member's package gain access
by inheritance
protected members inherited by subclasses in different packages are accessible
only to the subclass' own subclasses
Name access modifiers applicable to local vars
none
Local vars can be marked
final
Local var values
must be initialised
___ methods can't be overridden by subclasses
final
Declare an abstract method with
signature, return type and optional throws clause
3 indications of a non-abstract method
no abstract modifier, curly braces, code between curly braces
I can use the synchronized modifier only on
methods and code blocks
abstract methods cannot be marked ___ or ___
private, final
The ___ modifier applies only to methods
native
strictfp can only be used with
classes and methods
I declare var-arg param with what syntax?
type... name
How many var-arg params can a method have
one
Where a method takes var-args and normal params
var-arg must be listed first
SCJP 6 declarations and access control — Braineos