0% found this document useful (0 votes)
3 views4 pages

Java Full Notes Unit2 To 5

The document covers Java programming concepts from Units 2 to 5, including inheritance, interfaces, packages, exception handling, multithreading, AWT and Swing components, and network programming. Key topics include the use of 'extends' for inheritance, try-catch for exception handling, and socket programming for client-server communication. It provides code examples for each concept to illustrate their implementation.

Uploaded by

patole823212
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Java Full Notes Unit2 To 5

The document covers Java programming concepts from Units 2 to 5, including inheritance, interfaces, packages, exception handling, multithreading, AWT and Swing components, and network programming. Key topics include the use of 'extends' for inheritance, try-catch for exception handling, and socket programming for client-server communication. It provides code examples for each concept to illustrate their implementation.

Uploaded by

patole823212
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Programming Notes (Unit 2 to Unit 5) Exam

Ready + Programs + Syntax

UNIT 2: Inheritance, Interface, Package

Inheritance

Inheritance allows one class to acquire properties and methods of another class using 'extends'
keyword.
class Animal {
void eat() { [Link]("Eating"); }
}
class Dog extends Animal {
void bark() { [Link]("Barking"); }
}

Interface

Interface is a collection of abstract methods. It is used for multiple inheritance.


interface A {
void show();
}
class B implements A {
public void show() {
[Link]("Hello");
}
}

Package

Package is a collection of related classes and interfaces.


package mypack;
public class Test {
public void display() {
[Link]("Hello Package");
}
}
UNIT 3: Exception Handling & Multithreading

Exception Handling

Exception is a runtime error handled using try-catch blocks.


try {
int x = 10/0;
} catch(Exception e) {
[Link](e);
}

Multithreading

Thread is a lightweight process. It is created using Thread class or Runnable interface.


class MyThread extends Thread {
public void run() {
[Link]("Thread running");
}
}
UNIT 4: AWT & Swing

AWT Components

AWT is platform dependent GUI toolkit.


Frame f = new Frame();
Button b = new Button("Click");
[Link](b);

Swing Components

Swing is platform independent GUI toolkit.


JFrame f = new JFrame();
JButton b = new JButton("Click");
[Link](b);

Event Handling

Event handling is used to respond to user actions.


[Link](this);
UNIT 5: Network Programming

Socket Programming

Socket is endpoint for communication between client and server.


Socket s = new Socket("localhost",5000);

InetAddress

Used to get IP address and hostname.


InetAddress ip = [Link]("[Link]");
[Link]([Link]());

Client Server Example


ServerSocket ss = new ServerSocket(5000);
Socket s = [Link]();

URL Class
URL url = new URL("[Link]
[Link]([Link]());

You might also like