Java

Java Basics

Java Variables & Data Types

Java Control Flow

Java Arrays

Java Methods

Java Classes & Objects

OOP Principles

Java Utilities

Error Handling

Collections Framework

Java File Handling

Advanced Java

Java Practical How-To's

Java

Java Basics

Java Variables & Data Types

Java Control Flow

Java Arrays

Java Methods

Java Classes & Objects

OOP Principles

Java Utilities

Error Handling

Collections Framework

Java File Handling

Advanced Java

Java Practical How-To's

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


Java Introduction Quiz

Q1: Who invented Java?

A. Dennis Ritchie
B. Bjarne Stroustrup
C. James Gosling
D. Guido van Rossum

Q2: What is the correct file extension for Java files?

A. .jav
B. .java
C. .class
D. .js

Q3: Which method is the entry point of a Java program?

A. start()
B. main()
C. run()
D. init()

Q4: What does JVM stand for?

A. Java Variable Manager
B. Java Virtual Machine
C. Java Version Module
D. Java View Mode

Q5: What will System.out.println("Hello"); output?

A. Nothing
B. hello
C. Hello
D. "Hello"

Go Back Top