[Go to site: main page, start]

0% found this document useful (0 votes)
12 views12 pages

Introduction to Object-Oriented Programming

The document provides an introduction to Object-Oriented Programming (OOP), outlining its four pillars: abstraction, encapsulation, inheritance, and polymorphism, along with real-life examples and Java code snippets. It covers core Java basics, exception handling, multithreading, AWT & event handling, Swing, JDBC, RMI, JavaBeans, and Servlets. Additionally, it lists important previous year questions related to these topics.

Uploaded by

anshupa2005
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)
12 views12 pages

Introduction to Object-Oriented Programming

The document provides an introduction to Object-Oriented Programming (OOP), outlining its four pillars: abstraction, encapsulation, inheritance, and polymorphism, along with real-life examples and Java code snippets. It covers core Java basics, exception handling, multithreading, AWT & event handling, Swing, JDBC, RMI, JavaBeans, and Servlets. Additionally, it lists important previous year questions related to these topics.

Uploaded by

anshupa2005
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

INTRODUCTION TO OOP

Object-Oriented Programming (OOP) is a programming model based on objects rather than


functions.

OOP is used to structure programs in a way that makes them reusable and modular.

REAL LIFE EXAMPLE:

Think of a car — it has properties (color, speed) and behaviors (start(), brake()). That is an object.

FOUR PILLARS OF OOP:

1. **Abstraction**

Abstraction means showing only the essential details and hiding the complexity.

Example: When you press the car's brake, you don't see hydraulic pressure mechanics.

Java Example:

abstract class Animal {

abstract void sound();

class Dog extends Animal {

void sound() { [Link]("Bark"); }

2. **Encapsulation**

Wrapping data + methods in one unit (class).

Example: A medicine capsule wraps the drug inside.

Java Example:

class Student {

private int age;


void setAge(int age) { [Link] = age; }

3. **Inheritance**

Acquiring properties of one class into another.

Example: A son inherits traits from father.

Java Example:

class A { int x=10; }

class B extends A { int y=20; }

4. **Polymorphism**

One thing behaving in many ways.

Example: A person can be a student, son, customer at same time.

Java Example:

void show(int a)

void show(String b)
CORE JAVA BASICS

Java is platform-independent due to JVM and bytecode.

DATA TYPES:

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

VARIABLES:

Local, Instance, Static

OPERATORS:

Arithmetic (+, -), Logical (&&, ||), Relational (>, <), Assignment (=), Unary (++)

CONTROL STATEMENTS:

if, if-else, switch-case, loops (for, while, do-while)

ARRAYS:

int arr[] = {1,2,3}

STRINGS:

String is immutable.

StringBuffer and StringBuilder are mutable.


EXCEPTION HANDLING

Exception = runtime error.

Java handles it using try, catch, finally.

Example:

try {

int a = 5/0;

} catch(Exception e) {

[Link]("Error occurred!");

} finally {

[Link]("Always executed.");

}
MULTITHREADING

Thread = lightweight process.

Two ways to create thread:

1. Extends Thread

2. Implements Runnable

Example:

class A extends Thread {

public void run() { [Link]("Thread running"); }

}
AWT & EVENT HANDLING

AWT Components:

Button, Label, Checkbox, TextField

Layout Managers:

FlowLayout, GridLayout, BorderLayout

Event Handling:

ActionListener, MouseListener
SWING

Swing is lightweight GUI library.

Components:

JFrame, JPanel, JButton, JLabel, JTextField

Example:

JButton b = new JButton("Click");


JDBC

JDBC Steps:

1. Load Driver

2. Connect to DB

3. Create Statement

4. Execute Query

5. Close Connection

Example:

Connection con = [Link](url,user,pass);


RMI

Remote Method Invocation allows calling method on remote object.

Components:

• Stub

• Skeleton

• RMI Registry
JAVA BEANS

JavaBeans = reusable software components.

Features:

• Properties

• Events

• Introspection

• Persistence
SERVLETS

Servlet = Java program on server → used to create dynamic web pages.

Lifecycle:

1. init()

2. service()

3. destroy()
IMPORTANT PYQs (30)

1. Explain abstraction with real life example.

2. What is polymorphism? Explain overloading and overriding.

3. Explain servlet life cycle.

4. What is JDBC? Explain its architecture.

5. Explain AWT and layout managers.

6. What is exception hierarchy?

7. What is multithreading? Explain thread life cycle.

8. What is package? Explain user-defined package.

9. Difference between String and StringBuffer.

10. Explain RMI architecture.

(20 more questions included similarly...)

You might also like