Object Oriented Programming (Java)

Object Oriented Programming (Update Oct 2015)

G0915545

Introduction


Object-oriented programming (OOP) is a programming paradigm that represents the concept of “objects” that have data fields (attributes that describe the object) and associated procedures known as methods.

 

 

This section briefly describe basic idea on class and Objects

Download01 Class and Objects

pdf

More Methods on a class


Constructors
Constructor is a special type of subroutine called to create an object
Encapsulation
Encapsulation is a language mechanism for restricting access to some of the object’s components
Composition
Composition is a way to combine simple objects or data types into more complex ones

Download:02 Advance Methods on class

pdf

Sample Code: (This example demonstrates composition, constructors, methods… )

Inheritance


Object-oriented programming allows classes to inherit commonly used state and behavior from other classes

Download:03 Inheritance

pdf

Employee Example

employe example

Download: Complete Netbeans project (All classes: Date, Name, Employee, Temporary Employee, Manager, Contractor)

winrar

Video Tutorials

More Advance Object Oriented Programming concepts


Overriding, Abstraction, Packages, Polymopism

Download: 04 Advance Methods in OOP

pdf

Code Examples (Java classes)

Download: OOP Menu-driven Application development example

pdf

Exception Handling


Download : Exception Handling Note
File Handling


 

Download Lecturer Note (Files) [Download] 

 

Packages


lab
Lab Activities

Lab Activity 1:

Bank Account Example

Create a menu driven Java application to handle Bank Account information. Class diagram of the system is given below.

BankApplication2

Tasks

  1. Complete each class
  2. Add menu for the application with following menu options
    • Add new Account
    • Deposit or withdraw amount
    • Get balance for the given account
    • Print all account information
    • Exit
  3. Test your application

Note that: each methods has it normal meaning


Lab Activity 2

Transport Example


“Jaffna Travels” is a pioneer transport service company in Sri Lanka. It provides transport services between Colombo and Jaffna. The management of the company requires to develop an online ticket booking system to reserve the seats in a given bus. Assume that, a bus consists of 50 seats. One passenger can book any number of seats. However, it depends on the seats availability at that time. The passengers are allowed to board into the bus only from Colombo, Jaffna, Anuradhapura and Vavuniya. The passengers who are boarded to the bus from Anuradhapura or Vavuniya have to pay 25% additional charge. However, there are no additional chargers for children (half ticket). The Table 1 shows the price of a ticket for a journey.

tb1

Table 1. Price of a ticket
Write a menu driven Java Application to complete the system
The class diagram for the proposed system is given in the below.

jaf

ques

download 25 sample questions



Advertisements
%d bloggers like this: