Introduction
Introduction
A school program needs reliable data and clear rules. Java describes instructions that a compiler checks and turns into bytecode. A compatible Java Virtual Machine, or JVM, runs that bytecode. A school report is a useful first example: store marks, make a decision and display the result.
Understand
Java describes instructions that a compiler checks and turns into bytecode.
Apply
Trace the Java example, predict its output and explain the result before running it.
Avoid mistakes
Java has primitive values as well as objects. Portability still depends on a compatible runtime and any external libraries or files.
What is Java?
Java is a high-level programming language.
Java was created by a company called Sun Microsystems, which is now part of Oracle. One of Java's biggest advantages is that you can write your code once and run it on any computer that supports Java — this is often described as "write once, run anywhere."
Why Should You Learn Java?
Java has stood the test of time. It’s not just a legacy language; it continues to thrive in areas such as:
- Web Applications – Enterprise apps powered by Java frameworks like Spring and Jakarta EE.
- Mobile Development – Android apps are primarily written in Java or Kotlin.
- Big Data – Hadoop and other big data tools often rely on Java.
- Banking & Finance – Java’s robustness and security make it ideal for transaction-heavy systems.
- Cloud & Distributed Systems – Java supports scalable backend development for cloud-native systems.
Java's Philosophy: WORA
One of Java’s core strengths is its mantra: Write Once, Run Anywhere (WORA). This means the same Java program can run on any system that has a compatible JVM, regardless of operating system or hardware architecture.
Key Features of Java
Java isn’t just popular by accident. Here are some compelling features:
- Platform Independent: Bytecode runs on a compatible JVM; native dependencies and newer class versions can limit portability.
- Object-Oriented: Java has objects and primitive values; int and boolean are primitive types.
- Secure: Java has strong memory management and no explicit pointer manipulation.
- Multithreaded: Java natively supports multithreading, making it excellent for performance.
- Robust: Java handles runtime errors gracefully and emphasizes compile-time error checking.
Prerequisites to Learn Java
Before learning Java, it's helpful to have a basic understanding of the following topics:
- Basic Computer Knowledge: Understanding how to use a computer, files, and folders.
- Logic and Problem-Solving Skills: Ability to think logically and break down problems into steps.
- Basic Mathematics: Familiarity with simple math concepts like variables, operators, and expressions.
- Understanding of Programming Basics: (Optional but helpful) Knowledge of basic concepts like loops, conditions, and variables. You may refer to Programming Basics, where we focus on concepts rather than any specific language.
- Text Editor/IDE Usage: Knowing how to use tools like Notepad, VS Code, or IntelliJ IDEA to write and save code.
With this introduction, lets start your Java journey!
Important boundaries and mistakes
Java has primitive values as well as objects. Portability still depends on a compatible runtime and any external libraries or files.
Try the school example
Before running this Java program, write down each line you expect to see. Identify the value, branch, object or exception responsible for each line. Then explain whether the following assumption is valid: Java has primitive values as well as objects.
Java 17 · Main.java · complete practice program
public class Main {
public static void main(String[] args) {
int marks = 72;
System.out.println("Student marks: " + marks);
}
}
Worked answer and reasoning
Java 17 · Main.java · source repeated for this answer
public class Main {
public static void main(String[] args) {
int marks = 72;
System.out.println("Student marks: " + marks);
}
}
Expected output
Student marks: 72Java describes instructions that a compiler checks and turns into bytecode. A compatible Java Virtual Machine, or JVM, runs that bytecode. A school report is a useful first example: store marks, make a decision and display the result.
Java has primitive values as well as objects. Portability still depends on a compatible runtime and any external libraries or files.
Run with javac Main.java, then java Main. The declaration of Main names the class; main starts the example, and println writes a complete output line.
Check your understanding
What to remember
Java describes instructions that a compiler checks and turns into bytecode. A compatible Java Virtual Machine, or JVM, runs that bytecode. A school report is a useful first example: store marks, make a decision and display the result. Java has primitive values as well as objects. Portability still depends on a compatible runtime and any external libraries or files.
Related explanations: Java Variables, Java If Statement - Syntax and Examples, Java Class - Blueprint of Objects, Exceptions in Java Introduction.
Supporting documentation: Official Java learning guide and Java 17 language specification.
Reaching the recap and completing the quizzes are separate milestones.