0% found this document useful (0 votes)
6 views14 pages

Introduction to Object-Oriented Programming

This document provides an introduction to object-oriented programming. It discusses structured programming versus object-oriented programming, defining that OOP allows for constructing programs using objects and their interactions. It then defines some key concepts of OOP including classes, objects, encapsulation, abstraction, inheritance, and polymorphism. An example student class is also provided, pointing out what is missing from it. Finally, the document outlines the course syllabus and closes with a quote about data structures.

Uploaded by

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

Introduction to Object-Oriented Programming

This document provides an introduction to object-oriented programming. It discusses structured programming versus object-oriented programming, defining that OOP allows for constructing programs using objects and their interactions. It then defines some key concepts of OOP including classes, objects, encapsulation, abstraction, inheritance, and polymorphism. An example student class is also provided, pointing out what is missing from it. Finally, the document outlines the course syllabus and closes with a quote about data structures.

Uploaded by

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

Introduction into

Object Oriented
Programming
Chapter 1

Faculty of Information Technology


Agenda
Structured Programming
Object-Oriented Programming
Why Object-Oriented Programming
Object-Oriented Programming Features
Course Syllabus

12/10/2023 Introduction to OOP 2


What is Structured Programming

• The structured programming allows


developing a program using a set
of modules or functions

• The object-oriented
programming allows constructing a
program using a set of objects and their
interactions

12/10/2023 PRESENTATION TITLE 3


What is Object Oriented Programming

• A class is the blueprint or template for its objects.


• Described through Name, Attributes and Methods.

• Objects are instances of a class.

• Each object has state, behavior and identity.


• You send messages to an object by making method calls

12/10/2023 Introduction to OOP 4


Class Examples

12/10/2023 Introduction to OOP 5


Why Object-
Oriented
Programming ?
Question and Answer !
Object Oriented Programming
Features
1 - Encapsulation: (Hiding Information , Wrapper)
• You don’t allow data to flow freely in your system.
• Wrap data and functions into single unit  Class.
• The reason for encapsulation:
• Putting restrcitions so components of an object are not accessed easily.
• Binding data with method.
• Promoting security.
• We will implement this thorugh getters and setters.
• Data protection : public, private, protected.

12/10/2023 PRESENTATION TITLE 7


Object Oriented Programming
Features
2 - Abstraction: (Isolation)
• Show essential features and hide details of implmentation in
background.

12/10/2023 Introduction to OOP 8


Object Oriented Programming
3 - Inheritance: (Reuse)
Features
• When one object requires the properties (attributes and methods) of another
object.
• The reason for inheritance:
• To avoid code duplication. Then easier to add extra attributes/methods

le s? Parent Class
mp
e e xa
r
Mo
Child Class

12/10/2023 PRESENTATION TITLE 9


Object Oriented Programming
Features
4 - Polymorphism (Different Behaviour)
• It means one name with different forms.

12/10/2023 PRESENTATION TITLE 10


Example Create Class Student
Public class student
{ Where is the Object here ?
public String name;
public int year;
What is missing here ?
Public void printHello()
{
[Link](“Hello Student ”+ name );
}

12/10/2023
}
Can you think of Class Car ?
PRESENTATION TITLE 11
Let’s go through
syllabus
16 Studying Weeks
3 Quizzes
1 Mid Exam
1 Final Exam
Bad programmers worry about the
code. Good programmers worry
about data structures and their


relationships.
Linus Torvalds

12/10/2023 Introduction to OOP 13


Thank you
This material was prepared from the Book:
Interactive Object-Oriented Programming in
Java- 2nd Edition
Vaskaran Sarcar

Common questions

Powered by AI

Structured programming involves developing a program using a set of modules or functions, each performing a specific task. In contrast, object-oriented programming constructs a program using a set of objects and their interactions. Objects are instances of classes, and they encapsulate state, behavior, and identity, allowing for more modular and interactive program design .

Encapsulation is essential in object-oriented programming because it hides information and restricts data flow within the system. By wrapping data and functions into a single unit (class), it promotes security and data protection. Encapsulation ensures that components of an object are not accessed directly, thereby protecting the integrity of the object by using access modifiers like public, private, and protected, typically implemented through getters and setters .

Structured programming focuses on dividing a problem into a hierarchy of functions or procedures, emphasizing the sequence of operations. In contrast, object-oriented programming emphasizes encapsulating data and functions that operate on the data within objects, promoting a model that reflects real-world entities and interactions. OOP's emphasis on data abstraction and encapsulated interaction provides a more natural and cohesive approach to managing complex systems .

A class in object-oriented programming serves as a blueprint or template for its objects. It is described through its name, attributes, and methods. Objects, which are instances of a class, possess state, behavior, and identity .

The public class 'Student', as presented, is missing several key attributes and methods to represent a real-world student completely. Additional attributes like 'gradeLevel', 'studentID', or 'coursesEnrolled' might be necessary. Methods such as 'enrollInCourse()', 'updateGrade()', or 'displayStudentInfo()' can enhance its functionality. These elements contribute to a fuller encapsulation of the student's behavior and characteristics in a programming context .

Encapsulation enhances data security in object-oriented programming by ensuring that data within an object cannot flow freely and is accessed only through defined methods. This limits external access to the internals of an object and reduces the risk of unintended interference or manipulation, thus maintaining data integrity and confidentiality. Encapsulation is achieved through access modifiers and controlled through methods like getters and setters .

Inheritance allows an object to acquire the properties (attributes and methods) of another object, which leads to code reusability by avoiding code duplication. This makes it easier to add extra attributes or methods to the derived class without modifying existing code, thus enhancing maintainability and scalability of the program .

Polymorphism is significant in object-oriented programming because it enables a single name to represent different forms, allowing objects to be treated as instances of their parent class while maintaining unique behaviors. This allows for generalization in code and the flexibility to add new classes with minimal modification to existing code .

Encapsulation, inheritance, and polymorphism interrelate to manage complexity by compartmentalizing data and behavior (encapsulation), enabling reusability and hierarchical structuring of classes (inheritance), and supporting method overloading and overriding for flexible and dynamic behavior (polymorphism). Together, they allow developers to model real-world entities, streamline interaction among components, and extend systems efficiently .

Abstraction plays the role of simplifying complex systems in object-oriented programming by focusing on essential features while hiding unnecessary details of the implementation. This allows developers to manage complexity by isolating a system's functionality and exposing only what is necessary for the use of the class or method, ultimately making it easier to handle and adapt complex systems .

You might also like