1-Building Blocks Flashcards
Java Development Kit(JDK)
contains the minimum software you need
javac
Converts .java source files into .class bytecode
What command converts .java source files into .class bytecode
javac
java
executes the program
What command executes the program?
java
jar
Packages files together
What command packages files together?
jar
javadoc
Generates documentation
What command generates documentation?
javadoc
What are 2 primary elements of Java classes?
1.Methods (functions, procedures)
2.Fields (variables)
What is an object?
A runtime instance of a class in memory.
An object is often referred to?
As an instance.
What does an instance represent?
A single representation of the class.
What is a reference?
A variable that points to an object.
What are methods and fields of a class called together?
Members
What is a top-level type?
A data structure that can be defined independently within a source file/
Is it possible to have 2 top-level types in the same file?
yes, at most on of those is allowed to be public. And the public top-level type needs to match the filename.
What do you call the shortcut for both javac and java? for example java Zoo.java ...args
single-file source-code
Naming conflicts: What if you need two Classes with the same name from different packages?
- pick one to use in the import statement and use the other fully qualified class name.
2.Use the fully qualified class name for both.
Compiling with wildcards: how do you use an asterisk with javac command?
you specify to include all Java files in a directory, cannot be used to include subdirectories.
compiling to another directory?
javac -d directoryname package/class.java
how to run programs compiled to another directory?
java -cp/-classpath/–class-path directoryname packagename.Classname
What are important javac options?
- -cp <classpath></classpath>
- -classpath <classpath></classpath>
- –class-path <classpath></classpath>
- -d <dir></dir>
What are important java options?
- -cp <classpath></classpath>
- -classpath <classpath></classpath>
- –class-path <classpath></classpath>
What are important jar options?
- -c (creates a new JAR file)
–create - -v (prints details when working with JAR files
–verbose - -f <fileName> JAR filename
--file <fileName></fileName></fileName> - -C <directory> (Directory containing files to be used to create the JAR</directory>
rules for what Java file contains
- Each file can contain only one public class
- The filename must match the class name, including case, and have .java extension
- If entry point for the program, must contain valid main() method.
Which modifiers are optional in the next main() method:
public final static void main(final String[] args) {}
Both final modifiers
How do you call the following:
java Zoo.java zoo
shortcut for: javac Zoo.java \n java Zoo Zoo
launching single-file source-code programs
Required?
Package declaration
package abc;
No
Required?
import statements
import java.util.*;
No