Chapter 1 Flashcards
What are the key (identifying) benefits of Java
- Object Oriented
- Encapsulation
- Platform independent
- Robust
- Simple
- Secure
- Multithreaded
- Backward Compatibility
What key pieces does the Java Development Kit contain?
- The compiler (javac)
- The launcher (java)
- The Java Virtual Machine (JVM)
- javadoc
- jar
What is an object?
A runtime instance of a class in memory
What is a reference?
A variable that points to an object.
What are the two primary elements of a Java class?
Methods and fields.
What is the simplest valid Java class we can write?
public class Animal { }
The method signature consists of .. ?
The method name and parameters.
Does Java require a class to be public?
Java does not require a class to be public
Given a file with two or more classes, how many are allowed to be public? How many must be public?
Only one is allowed to be public (must match file name) & none are required.
Where does Java begin execution?
By calling the main() method.
What command do we use to check the version of java?
java -version
Using the terminal, how can we compile and then run the file Zoo.java?
- javac Zoo.java
2. java Zoo
Using the terminal with single-file source-code, how can we compile and then run the file Zoo.java?
- java Zoo.java
What is the constraint of single-file source-code?
It can only be used if your program contains one file.
What are the differences between using the commands javac + java and single-file source-code to compile and run a program?
Full command
- need to use two commands
- Produces a class file
- For any program
- Can import code in any available Java library
Single-file source-code
- one command
- Fully in memory (no class files)
- For programs with one file
- Can only import code that came with the JDK