Java U 1 Lec 1 Notes Marked PDF
Java U 1 Lec 1 Notes Marked PDF
Today’s Target
What is Java?
Java Source File Structure
Compilation and Execution
Java Environment
JDK
JRE
JVM
Object Oriented Programming with Java
What is ‘Java’?
"Java is an object-oriented, high-level programming language."
Class Definition
In Java, every program must be enclosed in a class.
A class represents a set of similar objects.
It is recommended that the class name matches the file name.
The basic structure of a class looks like the following:
class HelloJava
{
...
}
Object Oriented Programming with Java
Main Method
The main method is the starting point of every Java program. When we run a Java program, execution
begins from the main method.
- Signature of the Main Method
The standard syntax of the main method is: public static void main(String args[])
Main Method
The body of the main method contains the actual instructions to be executed. Statements inside the
method are written inside curly braces {}.
System.out.println("Hello, Java!");
prints text on the screen.
javac is the Java compiler that converts Java source code into bytecode.
If there are no errors, it generates a file: HelloJava.class .
This .class file contains bytecode, which is not machine-specific but can be executed on any platform
with a JVM.
Java Environment
JDK (Java Development Kit)
The JDK is a complete software development package that includes everything needed to
develop, compile, and run Java applications. It contains the JRE (Java Runtime Environment)
and development tools like the Java compiler (javac), debugger, and other utilities. Without the
JDK, we cannot develop and compile Java programs.