Exam Essentials 1 bag 41 Flashcards
Be able to write code using a main() method.
A main() method is usually written as public static void main(String[] args).
Arguments are referenced starting with args[0]. Accessing an argument that wasn’t passed in will cause the code to ___ an ___
throw and exception
Understand the effect of using packages and imports.
A ___ has the same name as the ____.
It looks like a method without a ____ ____
constructor
return type
Be able to identify legal and illegal declarations and instantiations.
Multiple variables can be ____ and _____ in the same statement when they share a ___.
declared
instantiated
type
___ variables require an explicit initialization.
Local variables
_____ may contain:
____, ____, ___ and ___.
Identifiers letters numbers $ _
Identifiers may not begin with ____
numbers
_____ ____ may contain ____ between numbers.
Number literals
underscores
Number literal may begin with _- _ (decimal) _ (octal) \_\_ and \_\_ (hex) \_\_ and \_\_ (binary)
0-1
0
0x and 0X
0b and 0B
Be able to determine where variables go into and out of scope.
All variables go into scope when they are ___.
declared
____ variables go out of scope when the block they are declared ___
local
ends
____ variables go out of scope when the object is garbage collected.
instance variables
___ variables remain in scope as long as the program is running.
class variables
An instance variable goes out of scope when the object is ___ ____
garbage collected
Class variables remain in scope as long as the ___ is running
program
Be able to recognize misplaced statements in a class.
T or F
Package and imports statements are optional.
True
In what order does package and imports statement go?
package statement
import statment
T or F Does the package and import statement go after the class declaration?
False. They go before the class declaration
T or F
Are fields and methods optional?
True
In what order are fields and methods allowed within the class declaration.
In any order
Know how to identify when an object is eligible for garbage collection.
Draw a diagram to keep track of references and objects as you trace the code.
- When no arrows point to a box (object), it is eligible for garbage collection.
:)
You got this!
T or F
Identifiers apply to anything you are free to name?
True
Whare are examples of identifiers which you are free to name?
variables
methods
classes and
fields
What are the only three rules for legal identifiers?
- The name must begin with a __ or the symbol _ or _.
- Subsequent characters may also be ___.
- You cannot use the same name as a Java __ word.
- The name must begin with a letter, symbol & or underscore.
- numbers
- Reserved
What is a reserved word?
A reserved word is a keyword that Java has reserved.
You are not allowed to use it.
T or False
Java is case sensitive
True
Name one reserved word
Class