-
What are the reserved literals?
null, true, false
-
What are the reserved keywords not in use?
const, goto
-
What are the integer data types?
int, long, byte, short
-
What must identifiers start with?
letter, $, _ or other connector
-
What can identifiers NOT start with?
a number
-
What is the max length of a Java identifier?
There is no limit
-
Are Java identifiers case sensitive?
Yes
-
What can a Java identifier contain after the first character?
any combination of letters, currency characters, connecting characters, or numbers
-
Legal or illegal identifier: .f
illegal cannot start with a .
-
Legal or illegal identifier: _$szygy
legal
-
Standard for naming Classes and Interfaces
CamelCase (i.e. MyGreatJavaClass)
-
Standard for naming Methods
first letter lowercase, remainder CamelCase (i.e. myMethodActing)
-
Standard for naming variables
first letter lowercase, remainder CamelCase (i.e. myMethodActing)
-
Standard for naming constants
UPPERCASE with _ as a separator (i.e. MIN_HEIGHT)
-
The name of a Java class file...
must match the name of the public class if there is one
-
A Java file with no public classes can have what type of name?
It can have any legal name
-
Class Access modifiers
public, protected, private - default access has no modifier
-
What are the nonaccess class modifiers?
strictfp, final, abstract
-
A subclass inheriting a member is exactly the same as...
The subclass declaring the member itself
-
How many public classes can be in a source file?
Exactly one
-
Where must the package statement be for classes in a package?
On the first line, before any import statements
-
Where must import statements go?
Between the package statement and any class declarations
-
Where must a class declaration go when there are no package or import statements?
It must be the first line of a source file
-
When can an abstract class be instantiated?
Never
-
What is the purpose of an abstract class?
To be extended (subclassed)
-
What does final mean when applied to a class?
A final class can't be subclassed
-
All interfaces are implicitly, what?
public and abstract
-
All variables defined in an interface must be what?
public, static, and final (i.e. constants)
-
Interface methods are 100% abstract
-
What are the member access control levels?
Public, Protected, default (if nothing specified), private
-
What must a class be declared as, to have an abstract method?
The class must be declared as abstract
-
A method cannot be both Abstract and ...?
Abstract and Final, Abstract and Private
-
Synchronized method keyword means
Method can only be accessed by one thread at a time
-
"native" means
That the method is implemented in platform-dependent code
-
"native" can only be applied to what?
methods - not classes or variables
-
strictfp can modify
a class or method declaration
-
strictfp means
enforce IEEE754 standard
-
What are var-args?
methods that take a variable number of arguments
-
How is a var-arg declared?
datatype followed by ... followed by the arg name
-
Which is legal: var test(int ... x) or var test(int ...)
var test(int ... x)
-
How many var-args can be in a method?
One
-
Where must the var-arg be in the parameter list?
at the end
-
What can't a constructor have?
a return type
-
How are constructors different from methods?
Constructors don't have a return type
- What are the eight primitive types?
- char, boolean, short, double, float, byte, int, long
-
a reference variable is used to
refer to or access an object
-
A byte datatype takes x bytes and y bits
1 byte, 8 bits
-
A short datatype takes x bytes and y bits
2 bytes, 16 bits
-
An int datatype takes x bytes and y bits
4 bytes, 32 bits
-
A long datatype takes x bytes and y bits
8 bytes, 64 bits
-
A float datatype takes x bytes and y bits
4 bytes, 32 bits
-
A double datatype takes x bytes and y bits
8 bytes, 64 bits
-
What is the range of byte, short, int, long?
(-2) ^ (bits -1) to (2 ^ (bits -1))-1
-
Instance variables are defined
inside the class, but outside any method
-
Which access levels can Instance variables use
any of the 4 access levels
-
What keyword can be used to resolve name collisions?
this
-
Is the statement int [5] scores; legal? If not, why?
No, cannot include the size of the array in the declaration
-
What keyword tells Java to skip an instance variable when serializing?
transient
-
What other keyword can only be applied to instance variables?
volatile
-
What keyword identifies a variable as shared by all instances of a class containing that variable?
variable
-
What things CAN be marked as static?
methods, variables, initialization blocks, a class nested in another class but not within a method
-
What things CAN'T be marked as static?
Constructors, classes (unless nested), Interfaces, Method Local Inner Classes, Inner Class methods and instance variables, local variables
-
Where CAN'T an enum be declared?
Within a method
- What are the escape characters?
- Big Farms Need Red Tractors - \b backspace, \f formfeed, \n newline \r carriage return \t horizontal tab \' single quote \" double quote \\ backslash
|
|