Object Oriented Programming Using Java
Object Oriented Programming Using Java
com
Page | 1
UNIT- I
Page | 2
Java was developed by Sun Microsystems (which is now the subsidiary of Oracle)
in the year 1995. James Gosling is known as the father of Java. Before Java, its
name was Oak. Since Oak was already a registered company, James Gosling and
his team changed the name from Oak to Java.
java Example
Simple.java
1. class Simple{
3. System.out.println("Hello Java");
4. }
5. }
Page | 3
Application
According to Sun, 3 billion devices run Java. There are many devices where Java
is currently used. Some of them are as follows:
4. Mobile
5. Embedded System
6. Smart Card
7. Robotics
8. Games, etc.
There are mainly 4 types of applications that can be created using Java
programming:
1 Standalone Application
Page |1
UNIT- II
Page |2
Inheritance in Java
Inheritance in Java is a mechanism in which one object acquires all the properties
and behaviors of a parent object. It is an important part of OOPs
The idea behind inheritance in Java is that you can create new classes that are
built upon existing classes. When you inherit from an existing class, you can reuse
methods and fields of the parent class. Moreover, you can add new methods and
fields in your current class also.
Sub Class/Child Class: Subclass is a class which inherits the other class. It
is also called a derived class, extended class, or child class.
Page |3
you create a new class. You can use the same fields and methods already
defined in the previous class.
2. {
4. }
The extends keyword indicates that you are making a new class that derives from
an existing class. The meaning of "extends" is to increase the functionality.
Page |1
UNIT-III
Page |2
Event Handling
Types of Event
Background Events - Those events that require the interaction of end user are
known as background events. Operating system interrupts, hardware or software
failure, timer expires, an operation completion are the example of background
events.
Event Handling
Event Handling is the mechanism that controls the event and decides what should
happen if an event occurs. This mechanism have the code which is known as event
handler that is executed when an event occurs. Java Uses the Delegation Event
Page |3
Model to handle the events. This model defines the standard mechanism to
generate and handle the events.Let's have a brief introduction to this model.
The Delegation Event Model has the following key participants namely:
Source - The source is an object on which event occurs. Source is responsible for
providing information of the occurred event to it's handler. Java provide as with
classes for source object.
Page |4
Page |1
UNIT - IV
Page |2
Multithreading in Java
1. It doesn't block the user because threads are independent and you can
perform multiple operations at the same time.
Multitasking
Page |3
A process is heavyweight.
Switching from one process to another requires some time for saving
and loading registers, memory maps, updating lists, etc.
A thread is lightweight.
Threads are independent. If there occurs exception in one thread, it doesn't affect
other threads. It uses a shared memory area.