The Java Development Kit (JDK) contains the minimum software you need to do Java development.
Key commands include:
javac : compiler, convert source file (.java) into bytecode (.class).java : launcher, launch Java Virtual Machine (JVM), JVM run bytecode on the actual machine.jar: archiver, package files togetherJavadoc: generate documentationJVM
Java Virtual Machine (JVM), JVM run bytecode on the actual machine.
JDK
Java Development Kit (JDK)
API
Java comes with a large suite of application programming interfaces (APIs) that you can use.
IDE
integrated development environment (IDE)
Java Release
Benefits of Java
1. Object Oriented
2. Encapsulation
3. Platform Independent
4. Robust
5. Simple
6. Secure
7. Multithreaded
8. Backward Compatibility
Java has some key benefits that you’ll need to know for the exam.
Understanding the Java Class Structure
What is class?
Class is the java basic building blocks, a template used to create objects and to define object data types and methods.
A class is the blueprint from which individual objects are created.
A Java class is a blueprint or template from which objects are created. It defines the data and methods that will be present in the objects of that class.
What are the syntax rules for defining a Java class?
(WIP)
In Java programs, classes are the basic building blocks. When defining a class, you describe all the parts and characteristics of one of those building blocks.
To use most classes, you have to create objects.
An object is a runtime instance of a class in memory.
An object is often referred to as an instance since it represents a single representation of the class.
All the various objects of all the different classes represent the state of your program.
A reference is a variable that points to an object.
What are Java class primary elements?
members of the class.FIELDS AND METHODS
Java classes have two primary elements:
methods, often called functions or procedures in other languages, and fields, more generally known as variables.
Together these are called the members of the class.
Variables hold the state of the program, and methods operate on that state.
What is object?
An object is a runtime instance of a class in memory. An object is often referred to as an instance since it represents a single representation of the class.
What is reference?
A reference is a variable that points to an object.
Class declaration
1: public class Animal {
2: }Add variable in class
1: public class Animal {
2: String name;
3: }Add method in class
1: public class Animal {
2: String name;
3: public String getName() {
4: return name;
5: }
6: public void setName(String newName) {
7: name = newName;
8: }
9: }Class declaration
(WIP)
Class declaration in Java refers to the process of defining a new class. It involves specifying the structure and behavior of the class, including its fields (variables), constructors, and methods. Here’s a breakdown of what class declaration entails:
Example:
public class MyClass {
// Class body containing fields, constructors, and methods
}
Class with field and method
public class Animal {
String name;
public String getName() {
return name;
}
public void setName(String newName) {
name = newName;
}
}What is method signature?
The method name and parameter types are called the method signature.
Type of Java Comment?
// comment until end of line
/* Multiple * line comment */
3.** Javadoc comment**:
/** * Javadoc multiple-line comment * @author Jeanne and Scott */
Java Comment
// comment until end of line
/* until the symbo*/. People often type an asterisk * at the beginning of each line of a multiline comment to make it easier to read, but you don’t have to./* Multiple * line comment */
/**. This special syntax tells the Javadoc tool to pay attention to the comment. Javadoc comments have a specific structure that the Javadoc tool knows how to read. You probably won’t see a Javadoc comment on the exam. Just remember it exists so you can read up on it online when you start writing programs for others to use./** * Javadoc multiple-line comment * @author Jeanne and Scott */