Chapter 1 - Declarations & Access Control Flashcards
What are reference variables used for?
used to refer to or access an object.
What are the eight Primitive Data Types?
Bits Bytes Byte 8 1 Long 64 8 Int 32 4 String Boolean vm dependent Char Double 64 8 Float 32 4
*once declared the type cannot change but value can.
What is a class?
A template that describes the kinds of state and behavior that objects of its type support.
What is a object?
At runtime, when the JVM encounters the new keyword, it will use the appropriate class to make an object that is a instance of that class.
What is state?
Each object (instance of class) will have its own unique set of instance variables as defined in the class. Collectively, the values assigned to an objects instance variables make up the objects state.
What is behavior?
(methods) when a programmer creates a class he/she creates methods for that class. Methods are where the classes logic is stored & where the real work gets done.
In Object Oriented Programming, what is inheritance?
It allows code defined in one class to be reused in another class. Ex: A superclass can have subclasses that have access to instance variables & methods & can override superclass methods to define more specific behavior. Car superclass Ferrari subclass accelerated( )
What is interfaces?
They are methods from a superclass that a subclass must support. No logic for the method(s) is defined by the interface.
What must legal identifiers start with?
They must start with either a letter (a), currency character ($), or connecting character ( _ ) .
What must a legal identifier NOT start with?
It must not start with a digit. 1234…
How many public classes per source file?
One public class per source file.
What line must the package statement be on?
The first line.
Where do import statements go in a source file?
Import statements go between package statements and class declarations or must be the first lines in source code file.
When does the file name not have to match the name of a class?
When the source file has no public classes.
In:
Public static void main(String[ ] args)
What is main?
main( ) is the method that the Java Virtual Machine (JVM) uses to start execution of a Java program.