Java Introduction


🔹 What is Java?

Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It was developed by James Gosling at Sun Microsystems and released in 1995.

Java programs are compiled into bytecode and run on the Java Virtual Machine (JVM), making them platform-independent.

 

🔹 Why Learn Java?

  • Write once, run anywhere (WORA) — platform-independent

  • Object-Oriented Programming (OOP) support

  • Large standard library

  • Used in Android development, web apps, enterprise software, etc.

  • Strong memory management and security features

 

🔹 Features of Java

  • Platform Independent

  • Object-Oriented

  • Simple and Secure

  • High Performance

  • Multithreaded

  • Portable and Robust

 

🔹 Java Program Structure

public class Main {
  public static void main(String[] args) {
    System.out.println("Hello, World!");
  }
}
🔸 Explanation:
  • class Main — defines the class

  • main() — entry point of Java programs

  • System.out.println() — prints output


🔹 How to Run Java Code

  1. Write the code in a file named Main.java

  2. Compile using:

    javac Main.java
  3. Run using:
    java Main
    

Practice Questions

Q1. Print "Hello Java"

Q2. Add two integers

Q3. Use single-line comment

Q4. Take user input using Scanner

Q5. Multiply two floating-point numbers


Go Back Top