0% found this document useful (0 votes)
5 views3 pages

Java

This document provides an overview of Java programming, covering its introduction, basic structure, data types, operators, control statements, functions, object-oriented programming principles, classes and objects, access modifiers, packages, exception handling, and arrays. It emphasizes Java's platform independence and the importance of the Java Virtual Machine. The content is aimed at beginners to intermediate learners seeking to understand foundational concepts in Java.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Java

This document provides an overview of Java programming, covering its introduction, basic structure, data types, operators, control statements, functions, object-oriented programming principles, classes and objects, access modifiers, packages, exception handling, and arrays. It emphasizes Java's platform independence and the importance of the Java Virtual Machine. The content is aimed at beginners to intermediate learners seeking to understand foundational concepts in Java.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

🟨 Java Class Notes

(Beginner to Intermediate Level)

📘 1. Introduction to Java
Java is a high-level, object-oriented, platform-independent programming language.

Developed by: Sun Microsystems (1995), now owned by Oracle.

WORA: Write Once, Run Anywhere — because of the JVM (Java Virtual Machine)

🧱 2. Basic Structure of Java Program


java
Copy
Edit
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
public – Access modifier

class – Defines the class

main() – Entry point

System.out.println() – Output to console

🧮 3. Data Types in Java


Type Example
int 10
float 3.14f
double 3.14159
char 'A'
boolean true / false
String "Hello"

➕ 4. Operators
Arithmetic: + - * / %

Relational: == != < > <= >=

Logical: && || !

Assignment: = += -= *= /=

Unary: ++ --

🔁 5. Control Statements
if-else
java
Copy
Edit
if (a > b) {
System.out.println("a is greater");
} else {
System.out.println("b is greater");
}
switch-case
java
Copy
Edit
switch (day) {
case 1: System.out.println("Monday"); break;
default: System.out.println("Invalid");
}
Loops
for, while, do-while

java
Copy
Edit
for (int i = 0; i < 5; i++) {
System.out.println(i);
}
🧰 6. Functions (Methods)
java
Copy
Edit
public int add(int a, int b) {
return a + b;
}
returnType functionName(parameters)

🧱 7. Object-Oriented Programming (OOP)


4 Pillars:
Encapsulation – Data hiding using classes

Inheritance – Using extends keyword

Polymorphism – Method Overloading / Overriding

Abstraction – Using abstract classes or interfaces

🧪 8. Classes and Objects


java
Copy
Edit
class Car {
String color;
void drive() {
System.out.println("Driving");
}
}
Car c = new Car();
🔐 9. Access Modifiers
public – accessible everywhere

private – within the class only

protected – within package + subclasses

default – within package

📂 10. Packages & Import


Use package to organize code

java
Copy
Edit
import java.util.Scanner;
🎯 11. Exception Handling
java
Copy
Edit
try {
int x = 5 / 0;
} catch (ArithmeticException e) {
System.out.println("Error: " + e);
} finally {
System.out.println("Done");
}
📚 12. Arrays
java
Copy
Edit
int[] arr = {1, 2, 3};
Multi-dimensional:

java
Copy
Edit
int[][] matrix = new int[3][3];

You might also like