JAVA PROGRAMMING NOTES (Simple
Explanation)
1. Introduction to Java
Java is a high-level, object-oriented programming language developed by James Gosling at Sun
Microsystems in 1995. It is used for desktop apps, mobile apps, web apps, and games.
Features of Java:
Simple, Object-Oriented, Platform Independent, Secure, Robust, Portable, Multithreaded,
Distributed.
2. Java Program Structure
Example:
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
3. Data Types
int, float, double, char, boolean, String.
4. Variables and Operators
Variables store data. Operators perform actions like +, -, *, /, ==, &&, ||.
5. Control Statements
if-else, switch, for loop, while loop, do-while loop.
6. Arrays
Used to store multiple values of same type.
int numbers[] = {10, 20, 30, 40};
7. Object-Oriented Programming Concepts
Class, Object, Encapsulation, Inheritance, Polymorphism, Abstraction.
8. Constructors
Special method to initialize objects.
9. Inheritance Example
class A { void showA(){} }
class B extends A { void showB(){} }
10. Exception Handling
try-catch blocks to handle runtime errors.
11. Input and Output
Scanner sc = new Scanner(System.in);
System.out.println("Enter your name:");
12. Packages
Used to group related classes.
13. Interfaces
interface Animal { void sound(); }
class Dog implements Animal { public void sound() { System.out.println("Bark"); } }
14. Multithreading
Allows multiple tasks to run at once.
15. Stack vs Heap Memory
Stack: Stores local variables and function calls (fast).
Heap: Stores objects and global variables (managed by Garbage Collector).