0% found this document useful (0 votes)
3 views

Java

The document provides comprehensive Java notes covering fundamental to advanced concepts, including basic syntax, data types, control statements, object-oriented programming, exception handling, and Java 8+ features. It also touches on Java GUI, JDBC, memory management, and keywords. The notes are structured for easy study and reference.

Uploaded by

my Udaipur
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Java

The document provides comprehensive Java notes covering fundamental to advanced concepts, including basic syntax, data types, control statements, object-oriented programming, exception handling, and Java 8+ features. It also touches on Java GUI, JDBC, memory management, and keywords. The notes are structured for easy study and reference.

Uploaded by

my Udaipur
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Here are detailed Java notes, covering fundamental to advanced concepts,

structured clearly for study or reference:

1. Introduction to Java

Developed by James Gosling at Sun Microsystems.

Platform-independent via Java Virtual Machine (JVM).

File extension: .java

Write Once, Run Anywhere (WORA)

2. Basic Syntax

Public class HelloWorld {

Public static void main(String[] args) {

System.out.println(“Hello, World!”);

}
3. Data Types

Primitive Types

Int, byte, short, long, float, double, char, boolean

Non-Primitive

Arrays, Strings, Classes, Interfaces

4. Variables and Constants

Int age = 25;

Final double PI = 3.14; // constant

5. Operators

Arithmetic: + - * / %

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


Logical: && || !

Assignment: = += -= *=

6. Control Statements

Conditional

If (x > 0) {

System.out.println(“Positive”);

} else {

System.out.println(“Non-positive”);

Loops

For, while, do-while

For (int I = 0; I < 5; i++) {

System.out.println(i);

}
7. Arrays and Strings

Int[] numbers = {1, 2, 3};

String name = “Java”;

String is an object, immutable, and supports many methods.

8. Methods (Functions)

Public static int add(int a, int b) {

Return a + b;

Supports method overloading.

9. Object-Oriented Programming

Class and Object


Class Car {

String color;

Void drive() {

System.out.println(“Driving “ + color + “ car”);

Car myCar = new Car();

Encapsulation

Using private fields and public getters/setters.

Inheritance

Class Animal {

Void speak() {

System.out.println(“Speaking”);

Class Dog extends Animal {

Void bark() {

System.out.println(“Barking”);

Polymorphism
Method Overloading (compile-time)

Method Overriding (run-time, with @Override)

Abstraction

Abstract Classes

Abstract class Shape {

Abstract void draw();

Interfaces

Interface Drawable {

Void draw();

10. Constructors

Class Person {
Person() {

System.out.println(“Constructor called”);

Can be overloaded.

11. Exception Handling

Try {

Int x = 10 / 0;

} catch (ArithmeticException e) {

System.out.println(“Error: “ + e);

} finally {

System.out.println(“Finally block executed”);

12. File Handling

Import java.io.*;

BufferedWriter writer = new BufferedWriter(new FileWriter(“output.txt”));


Writer.write(“Hello Java”);

Writer.close();

13. Collections Framework

Interfaces: List, Set, Map, Queue

Classes: ArrayList, HashSet, HashMap, LinkedList, TreeSet

14. Multithreading

Class MyThread extends Thread {

Public void run() {

System.out.println(“Thread running…”);

Use Thread class or Runnable interface.


15. Packages and Access Modifiers

Packages: group related classes.

Access: public, private, protected, default (no modifier)

16. Java 8+ Features

Lambda Expressions

(x, y) -> x + y;

Streams API

Functional Interfaces

Default and Static Methods in Interfaces

17. Java GUI (Swing)


JFrame frame = new JFrame(“Title”);

Frame.setSize(300, 200);

Frame.setVisible(true);

18. Java Database Connectivity (JDBC)

Connection con = DriverManager.getConnection(url, user, pass);

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery(“SELECT * FROM table”);

19. Java Memory Management

Automatic Garbage Collection

Memory areas: Heap, Stack, Method Area, etc.

20. Keywords

Class, interface, extends, implements, final, this, super, static, void, return,
try, catch, throws
Would you like this in PDF format, or need sample programs and exercises for
practice?

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy