You are on page 1of 32

Object Oriented Programming using Java

Lecture 01
An Introduction to the Course
Introduction

• Pre-requisite: Programming Fundamentals


– The most fundamental course and is going to form the foundation
for subsequent ones

• Credits: 3+1 Contact Hrs: 3+3


– Two lectures/per week 1 hour 15 mins each
– 3 hours lab/ week
Objective
• To introduce students the basic Object Oriented
programming skills with an aim to:

– Familiarize the most powerful features of Java


programming focusing on OOP methodology

– Emphasize the correct and proper use of object-


oriented support in Java
Recommended Books and Other Material

• Recommended Books
– Java How To Program by Dietel 11th Ed.
• Some good reference books are
– Beginning Java by Ivor Horton
– An Introduction to Object Oriented Programming with Java, 5th
Edition by C. Thomas Wu
• Lecture Slides
• Any other material on Object Oriented Programming
Course Contents

• Object Oriented Concepts


– Class Declaration,
– Class Members,
– Access Modifiers
– Encapsulation
– Information Hiding,
– Constructors etc
– Inheritance
– Polymorphism
Course Contents

• Introduction to object oriented design


• History and advantages of object oriented design
• Introduction to object oriented programming concepts
• Classes
• Objects
• Data encapsulation
• Constructors
• Garbage Collection
• Access modifiers
• const vs non-const functions
• static data members & functions
• Function overloading
Course Contents (contd.)

• Identification of classes and their relationships


• Composition, aggregation, inheritance
• Multiple inheritance
• Polymorphism
• Abstract classes and interfaces
• Generic programming concepts
• Function & class templates
• Standard template library
• Object streams, data and object serialization using object streams
• Exception handling.
Administrative

• Instructor: Dr. Arif Jamal


– arif.malik@fui.edu.pk
• Office hours:
– Monday 10:00am to 12:00pm
Quizzes

• Quizzes will generally be announced


• Missing a quiz means zero marks
• A Quiz may also be conducted at anytime during the lecture
Assignments

• There will be 3-4 assignments


• Related to the topics being studied in course
• DO NOT copy assignments
– Both of the copy cases will be graded zero
• Submission time will be 24 hrs on the due date
– 50% credit on 1 day LATE submission of any
deliverable.
– Zero credit after 1 day LATE
Lab Work

• Involves implementation of studied techniques and data


structures in Java.

• All the coding will be done in Java using NetBeans IDE (ver
8.2 or above)
• Each lab will comprise of a lab tasks/exercises to be
completed during the same lab time (3 Hrs.)
• Lab assignments will also be given to be submitted
individually
Project

• You will be required to do a project

• You will have full liberty to choose any application of your


choice.
Evaluation Breakdown

– Mid Term = 25%


– Final = 50%
– Assignments/Quizzes/Project = 25 %
Attendance Policy

• A person who comes late will also be marked absent.

• As per FURC attendance regulations, a student missing


more then 25% of the classes will not be eligible to appear
in final exam.
OOP
Why We Need OOP

• OOP was developed to overcome the limitations of the


traditional programming languages. Instruct
at each
step

• As the program gets larger in procedural programming it


becomes more complex to understand the logic and
implement.
Problems with structured approach
• Unrestricted access

Accessible by any function

Accessible Global Variables Accessible


only by only by
function A function B
Function A Function B

Local Variables local Variables


Problems with structured approach
-difficult to conceptualize
- Change in global variable
causes rewriting
dependent functions

Global Data Global Data Global Data

Function Function Function Function


Object Oriented Approach
• The fundamental idea behind object-oriented language is to
combine both in a single unit
– data and
– the functions that operate on that data.
– Such a unit is called an object

• Data and its functions are said to be encapsulated into a single


entity
• Data encapsulation and data hiding are the key terms in the
description of object oriented languages
Object Oriented Approach

Data

Member
Function

Member
Function

Object
Data
Data
Member
Member
Function
Function
Member Member
Function Function

Object Object
Real World Modeling

• In physical world we deal with objects such as cars and


people
• Such kind of objects are not like the data and are not like
the functions
• Complex real world objects have both attributes and
behavior
Attributes
• Sometimes called characteristics
• Example:
– People: Eye color and job title
– Cars: engine power and number of doors

• Attributes in the real world are equivalent to the data in a


program.
• They have certain specific values such as blue (for eye
color) and four (for the number of doors)
Behavior

• Behavior is something a real world object does in response


to some stimulus.
• Example:
– Saying something
– Stopping by applying brakes

• Behavior is like a function. You call a function to do


something.
Why Objects?

A new way to think about software


Industrial revolution -- reuse software, not rewrite
Increase
– programmer productivity
– quality of software
– understandability of software
– lifetime of software
Characteristics of Object Oriented Languages

• When you approach Object-Oriented Language you no


longer ask how the problem will be divided into functions,
but how it will be divided into objects.

• This results from the close match between objects in the


programming sense and objects in the real world
Kinds of Objects

• What kinds of things become objects in Object-Oriented


programs?
• Physical objects
– Automobiles in a traffic flow simulation
– Electrical components in a circuit-design program
– Countries in an economics model
– Aircraft in an air traffic control system
Kinds of Objects
• Elements of the computer-user environment
– Windows
– Menus
– Graphics objects (lines, rectangles, circles)
– The mouse, keyboard, disk drives, printer
• Human Entities
– Employees
– Students
– customers
OOP Methodology

• Objects are self-contained “mini-programs”


– Each object has a specific set of responsibilities
– Operations (methods), and data form an interface

• Reusable Components
– Design or build new applications from existing object components
– Build new objects from existing objects
Objects and Behavior

John goes on a trip. Can you


think of
John makes reservations. various
John buys tickets. possible
John travels by airplane. Objects?

John checks into hotel.


OOP Methodology
• A Programming Methodology
– A different way to think about problems
– Adopt a new programming “Mindset”

• Models Real World


– Easier to identify, conceptualize, explain and document

• Objects are Primary Focus


– Data and functions or responsibilities are united in OBJECTS
Java Compilation Process
Features of Java

You might also like