Ch1: Java Building Blocks Flashcards
What can identifier names start with?
A letter, an underscore, or a dollar sign
Identifier names can have which characters?
A letter, an underscore, or a dollar sign. Subsequent characters may also have numbers.
What is an object?
A runtime instance of a class in memory
What are class methods called in other languages?
Functions or Procedures
What is the Java term for a function or procedure in a class?
A method
What are we referring to when we talk about the members of a class?
Methods and fields
What is the general term for methods and fields in a class?
Members
What is another word for a field in a class?
Instance variable
What is another word for a class or instance level variable?
field
What is the method signature for a program entry point? (The “Main” method)
public static void main(String[] args)
For the program entry point, is the Main method uppercase or lowercase?
Lowercase:
public static void main(String[] args)
What is the command to compile a file called “zoo.java”?
javac zoo.java
What is the command to run the class file “zoo.class”?
java zoo
Which class is always imported by default?
java.lang.*
How do you specify other class paths when running a java program?
java -cp “.:/path1/foo.jar:/path2/*” myPackage.MyClass
What is an Instance Initializer?
A code block ( {..} ) outside of a method, but inside of a class.
When an object is created, what is the order of initialization?
- Static fields and static initializers, in order
- Instance variables and instance initializers, in order
- Constructors
What are the two types of data containers in Java?
Primitive types and reference types
List all primitive type keywords
boolean byte short int long float double char
What is byte?
8-bit integral value
What is short?
16-bit integral value
what is int?
32-bit integral value
what is long?
64-bit integral value
what is float?
32-bit floating-point value
what is double?
64-bit floating-point value
what is char?
16-bit Unicode value
What is boolean?
true or false
What is an example of a floating point literal?
123.45f
In order of size, what are the integral primitives?
byte > short > int > long
In order of size, what are the floating-point primitives?
float > double