OCA Summary 1 pag 40 Flashcards
Java classes consist of members called ___ and ___.
fileds and methods
An ___ is an instance of a Java class
object
There are three styles of comments:
single-line comment
multiline comment
Javadoc comment
Java beings program execution with a ____ method
main()
The most common signature for the main() method run from the command line is:
public static void main(String[] args)
Arguments are passed in after the ___ ___
class name
Arguments are indexed starting with ___
0
Java code is organized into folders called ____
packages
To reference classes in other packages, you use an ___ ____.
import statement
A wildcard ending an import statement means you want to import all ___ in that ____
classes
package
What is the special package that does not need to be imported?
java.lang
Constructors create Java ____
objects
A constructor is a method matching the ___ ___ and omitting the ___ ___
class name return type
When an object is instantiated, ___ and ____ of code are initialized first. Then the ___ is run.
fields and block of code
constructor
____ ____ are the basic building blocks of Java types. They are assembled into reference types.
Primitive types
Reference types can have methods and be assigned to ___
null
In addition “normal” numbers, ____ ____ are allowed to begin with 0 (___), 0x (__), 0X (___), 0b (___) or 0B (__).
numeric literals
octal
hex
binary
Numeric literals are also allowed to contain ___ as long as they are directly between two other ___
underscores
numbers
Declaring a variable involves starting the ___ ___ and giving the variable a ___.
data type
name
Variables that represent fields in a class are automatically initialized to their corresponding “___” or __ value during instantiation.
zero
null
___ variables must be specifically initialized.
Local
Identifiers may contain ___, ___, __, or __.
letters
numbers
$ (dollar sign)
_ (underscore)
Identifiers may not begin with ___
numbers
Scope refers to that portion of code where a variable can be ___
accessed
There are three kinds of variables in Java, depending on their scope:
Instance variables class variables local variables
___ variables are the nonstatic fields of your class
Instance variables
Instance variables are the non____ fields of your class
static
___ variables are the static fields within a class
class variables
___ variables are declared within a method
local variables
For some class elements, ___ matters within the file
order
T or F
The package statement comes first if present.
true
imports
Name the order in which class elements need to be:
methods
import statement
fields
package statement
package statement
imports
fileds and methods are allowed to be in any order within the class
___ ___ is responsible for removing objects from memory when they can never be used again.
Garbage Collection
An object becomes eligible for garbage collection when there are no more ___ to it or its ____ have all gone out of scope
references
The finalize() method will run ___ for each object if/when it is first garbage collected.
once
Java code is object oriented, meaning all ___ is ___ in ___.
All Code is Defined in Classes
____ ____ allow classes to encapsulate data.
Access modifiers
Access modifiers allow classes to ___ ___.
encapsulate data
Java is platform independent, ___ to bytecode
compiling
Java is platform independent, compiling to ___
bytecode
Java is robust and simple by not providing ___ or operator ___.
pointers
operator overloading
Java is secure because it runs inside a ____ ____
virtual machine