Sunday, May 10, 2026

Quick Recall_Java

```html

Java Quick Review (Exam Fast Revision)

Unit 1: Java Fundamentals

What is Java?

  • High level, object-oriented programming language
  • Platform independent → “Write Once, Run Anywhere”
  • Uses JVM (Java Virtual Machine)

OOP Concepts

  1. Class → blueprint
  2. Object → real instance
  3. Encapsulation → data hiding
  4. Inheritance → reuse code
  5. Polymorphism → many forms
  6. Abstraction → hide details

Basic Program

class Hello {
    public static void main(String args[]) {
        System.out.println("Hello");
    }
}

JDK

  • JDK = Java Development Kit
  • Contains compiler (javac) + JVM + libraries

Data Types

Type Example
int 10
float 2.5f
double 5.67
char 'A'
boolean true
String "Hello"

Variables & Constants

int a = 5;
final int x = 10;

final = constant value cannot change.

Operators

Operator Example
Arithmetic + - * / %
Relational > < == !=
Logical && || !
Assignment = += -=

Type Casting

double x = 5.5;
int y = (int)x;

Control Statements

if

if(a>5){
   System.out.println("Yes");
}

switch

switch(n){
 case 1:
   break;
 default:
}

Loops

for

for(int i=0;i<5;i++)

while

while(condition)

do while

do{
}while(condition);

Array

int a[] = {1,2,3};

String

String s = "Java";
s.length();
s.toUpperCase();

Unit 2: Classes, Objects & Methods

Class and Object

class Student{
   int id;
}

Student s = new Student();

Method

void show(){
   System.out.println("Hello");
}

Constructor

Student(){
   System.out.println("Constructor");
}
  • Same name as class
  • No return type
  • Automatically called

this keyword

this.id = id;

Used to refer current object.

static keyword

static int count;

Shared by all objects.


Unit 3: Inheritance & Interfaces

Inheritance

class A{}
class B extends A{}

Types:

  • Single
  • Multilevel
  • Hierarchical

super keyword

super();
super.x;

Calls parent class members.

Method Overriding

class A{
   void show(){}
}

class B extends A{
   void show(){}
}

Polymorphism

One method → many forms.

A obj = new B();

final keyword

Usage Meaning
final variable cannot change
final method cannot override
final class cannot inherit

Abstract Class

abstract class A{
   abstract void run();
}

Cannot create object.

Interface

interface A{
   void show();
}

Used for full abstraction.

Access Specifiers

Specifier Access
public everywhere
private inside class
protected package + subclass
default same package

Unit 4: Exception Handling & Multithreading

Exception Handling

try{
}
catch(Exception e){
}
finally{
}

Keywords:

  • try
  • catch
  • throw
  • throws
  • finally

Thread

Extending Thread

class A extends Thread{
   public void run(){
   }
}

Runnable Interface

class A implements Runnable{
   public void run(){
   }
}

Start thread:

t.start();

Unit 5: File Handling & I/O

Scanner

Scanner sc = new Scanner(System.in);
int x = sc.nextInt();

File Writing

FileWriter fw = new FileWriter("a.txt");
fw.write("Hello");
fw.close();

File Reading

FileReader fr = new FileReader("a.txt");

Streams

Stream Meaning
Byte Stream binary data
Character Stream text data

Random Access File

RandomAccessFile f =
new RandomAccessFile("a.txt","rw");

Can access any position directly.


Unit 6: Swing & JDBC

Swing

Used for GUI.

Components

Component Use
JButton button
JTextField text box
JCheckBox checkbox
JList list

Event Handling

button.addActionListener(this);

Layout Managers

Layout Work
FlowLayout left to right
BorderLayout north south east west
GridLayout grid form

JDBC

Java Database Connectivity

Steps

  1. Import package
  2. Load driver
  3. Create connection
  4. Execute query
  5. Close connection

JDBC Example

Connection con =
DriverManager.getConnection(
"jdbc:mysql://localhost/test",
"root",""
);

Statement st = con.createStatement();

st.executeUpdate(
"insert into student values(1,'Ram')"
);

Most Important Viva Questions

Difference between JDK, JRE, JVM

Term Meaning
JVM runs bytecode
JRE JVM + libraries
JDK JRE + compiler

Difference between Method and Constructor

Method Constructor
has return type no return type
called manually called automatically

Difference between Abstract Class and Interface

Abstract Class Interface
partial abstraction full abstraction
can have normal methods mainly abstract methods

Super Important Programs For Exam

  1. Class and Object
  2. Constructor
  3. Inheritance
  4. Method Overriding
  5. Interface
  6. Exception Handling
  7. Multithreading
  8. File Handling
  9. Swing GUI
  10. JDBC CRUD

Last Minute Tips

  • Remember syntax carefully.
  • Write semicolon ;
  • main() syntax is important
public static void main(String args[])
  • extends → inheritance
  • implements → interface
  • try-catch-finally always together
  • Thread starts with start(), not run()

Good luck for your exam 👍

```

0 comments:

Post a Comment