CMP-2123-Object Oriented Programming Lecture 1.1 By Abrar Ahmad Abrar.ahmad14@ce.ceme.edu.pk
Course Introduction •Prerequisites •Programming Fundamentals •Course Objective •This course aims to develop students’ Objects oriented programming skills. 2arbabwaseer@gmail.com
Course Introduction •Textbook •Java Programming From the Ground Up by Ralph Bravaco and Shai Simonson, McGraw-Hill Higher Education New York, 2010, ISBN: 978-0-07-352335-4 •Ivor Horton’s Beginning Java by Ivor Horton, John Wiley & Sons, Inc. 7th Edition, 2011, ISBN: 978-0-470- 40414-0 3arbabwaseer@gmail.com
Course Introduction •Reference Material •Java TM Programming by Joycee Farrell,6th Edition, Cengage Learning, 2012, ISBN-13: 978-1-111- 52944-4 •Java TM How to Program By Paul Deitel and Harvery Deitel, Pearson,9th Edition, 2012, ISBN-13: 978-0- 13-257566-9 4arbabwaseer@gmail.com
Course Overview • Objects and Classes, Abstraction Encapsulation • Final Classes, Nested and Inner Classes • Inheritance, Abstract Classes, Concrete Classes, Inheritance and Encapsulation • The is-a Relationship, Inheritance via Abstract Classes, Extending the Hierarchy, Upcasting and Downcasting, Interfaces 5arbabwaseer@gmail.com
Course Overview • Composition, has-a Relationship • Polymorphism • Dynamic Binding • Interfaces and Polymorphism 6arbabwaseer@gmail.com
Course Overview •The Wrapper Classes, Boxing and Unboxing Packages •Exceptions and Exception Handling •File System and paths, File Directory Handling and Manipulation, Input/Output Streams, Reading Binary Data, Writing Binary Data, Writing Text, reading text, Logging with PrintStream, Random Access Files, Serialization •Collection for-each Loop 7arbabwaseer@gmail.com
Course Overview • GUI Concepts, Components and Containers, Abstract Windows Toolkit and Swing, Windows and Frames, Layout Managers, Panels • Event-Driven Programming, The Delegation Event Model • Event Classes, Mouse Events, Keyboard Events, Using Actions • Component and Jcomponent, Buttons, Labels, Text Fields, Text Areas, Dialog Boxes, Checkboxes, and Radio Buttons, Menus, Jslider, JTabbedPane 8arbabwaseer@gmail.com
What is OOP • Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic. • Historically, a program has been viewed as a logical procedure that • takes input data • processes it • produces output data. • The programming challenge was seen as how to write the logic, not how to define the data. 9arbabwaseer@gmail.com
What is OOP • Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. • Example • Human Being • Name • Height • Age • Gender • Race • etc 10arbabwaseer@gmail.com
What is OOP •Object Oriented Programming is an engineering approach for building software systems •Based on the concepts of •Classes •Objects That are used for modeling the real world entities. 11arbabwaseer@gmail.com
Why OOP •Better suited for team development •Facilitate utilizing and creating reusable components. •Easier GUI Programming •Easier Software maintenance 12arbabwaseer@gmail.com
Principles of OOP •Inheritance •Abstraction •Encapsulation •Polymorphism 13arbabwaseer@gmail.com
About • Simula is considered as the first object-oriented programming language. The programming paradigm where everything is represented as an object, is known as truly object-oriented programming language. 14arbabwaseer@gmail.com
OOP • Object means a real word entity such as pen, chair, table etc. Object- Oriented Programming is a methodology or paradigm to design a program using classes and objects. It simplifies the software development and maintenance by providing some concepts: • Object • Class • Inheritance • Polymorphism • Abstraction • Encapsulation 15arbabwaseer@gmail.com
Object: Any entity that has state and behavior is known as an object. For example: chair, pen, table, keyboard, bike etc. It can be physical and logical. 16arbabwaseer@gmail.com
• Syntax to declare a class: •Class • Collection of objects is called class. It is a logical entity. 17arbabwaseer@gmail.com
Simple Example of Object and Class • In this example, we have created a Student class that have two data members id and name. We are creating the object of the Student class by new keyword and printing the objects value. 18arbabwaseer@gmail.com
19arbabwaseer@gmail.com
20arbabwaseer@gmail.com
•Polymorphism • When one task is performed by different ways i.e. known as polymorphism. For example: to convince the customer differently, to draw something e.g. shape or rectangle etc. • In java, we use method overloading and method overriding to achieve polymorphism. • Another example can be to speak something e.g. cat speaks meaw, dog barks woof etc. •Inheritance • When one object acquires all the properties and behaviors of parent object i.e. known as inheritance. It provides code reusability. It is used to achieve runtime polymorphism. 21arbabwaseer@gmail.com
22arbabwaseer@gmail.com
• Abstraction • Hiding internal details and showing functionality is known as abstraction. For example: phone call, we don't know the internal processing. • In java, we use abstract class and interface to achieve abstraction. •Encapsulation • Binding (or wrapping) code and data together into a single unit is known as encapsulation. For example: capsule, it is wrapped with different medicines. • A java class is the example of encapsulation. Java bean is the fully encapsulated class because all the data members are private here. 23arbabwaseer@gmail.com
24arbabwaseer@gmail.com
Advantage of OOPs over Procedure- oriented programming language • OOPs makes development and maintenance easier where as in Procedure-oriented programming language it is not easy to manage if code grows as project size grows. • OOPs provides data hiding whereas in Procedure-oriented programming language a global data can be accessed from anywhere. • OOPs provides ability to simulate real-world event much more effectively. We can provide the solution of real word problem if we are using the Object-Oriented Programming language. 25arbabwaseer@gmail.com
26arbabwaseer@gmail.com
•What is difference between object-oriented programming language and object-based programming language? • Object based programming language follows all the features of OOPs except Inheritance. JavaScript and VBScript are examples of object based programming languages. 27arbabwaseer@gmail.com

Lec 1.1 Object Oriented Programming

  • 1.
  • 2.
    Course Introduction •Prerequisites •Programming Fundamentals •CourseObjective •This course aims to develop students’ Objects oriented programming skills. 2arbabwaseer@gmail.com
  • 3.
    Course Introduction •Textbook •Java ProgrammingFrom the Ground Up by Ralph Bravaco and Shai Simonson, McGraw-Hill Higher Education New York, 2010, ISBN: 978-0-07-352335-4 •Ivor Horton’s Beginning Java by Ivor Horton, John Wiley & Sons, Inc. 7th Edition, 2011, ISBN: 978-0-470- 40414-0 3arbabwaseer@gmail.com
  • 4.
    Course Introduction •Reference Material •JavaTM Programming by Joycee Farrell,6th Edition, Cengage Learning, 2012, ISBN-13: 978-1-111- 52944-4 •Java TM How to Program By Paul Deitel and Harvery Deitel, Pearson,9th Edition, 2012, ISBN-13: 978-0- 13-257566-9 4arbabwaseer@gmail.com
  • 5.
    Course Overview • Objectsand Classes, Abstraction Encapsulation • Final Classes, Nested and Inner Classes • Inheritance, Abstract Classes, Concrete Classes, Inheritance and Encapsulation • The is-a Relationship, Inheritance via Abstract Classes, Extending the Hierarchy, Upcasting and Downcasting, Interfaces 5arbabwaseer@gmail.com
  • 6.
    Course Overview • Composition,has-a Relationship • Polymorphism • Dynamic Binding • Interfaces and Polymorphism 6arbabwaseer@gmail.com
  • 7.
    Course Overview •The WrapperClasses, Boxing and Unboxing Packages •Exceptions and Exception Handling •File System and paths, File Directory Handling and Manipulation, Input/Output Streams, Reading Binary Data, Writing Binary Data, Writing Text, reading text, Logging with PrintStream, Random Access Files, Serialization •Collection for-each Loop 7arbabwaseer@gmail.com
  • 8.
    Course Overview • GUIConcepts, Components and Containers, Abstract Windows Toolkit and Swing, Windows and Frames, Layout Managers, Panels • Event-Driven Programming, The Delegation Event Model • Event Classes, Mouse Events, Keyboard Events, Using Actions • Component and Jcomponent, Buttons, Labels, Text Fields, Text Areas, Dialog Boxes, Checkboxes, and Radio Buttons, Menus, Jslider, JTabbedPane 8arbabwaseer@gmail.com
  • 9.
    What is OOP •Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic. • Historically, a program has been viewed as a logical procedure that • takes input data • processes it • produces output data. • The programming challenge was seen as how to write the logic, not how to define the data. 9arbabwaseer@gmail.com
  • 10.
    What is OOP •Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. • Example • Human Being • Name • Height • Age • Gender • Race • etc 10arbabwaseer@gmail.com
  • 11.
    What is OOP •ObjectOriented Programming is an engineering approach for building software systems •Based on the concepts of •Classes •Objects That are used for modeling the real world entities. 11arbabwaseer@gmail.com
  • 12.
    Why OOP •Better suitedfor team development •Facilitate utilizing and creating reusable components. •Easier GUI Programming •Easier Software maintenance 12arbabwaseer@gmail.com
  • 13.
  • 14.
    About • Simula isconsidered as the first object-oriented programming language. The programming paradigm where everything is represented as an object, is known as truly object-oriented programming language. 14arbabwaseer@gmail.com
  • 15.
    OOP • Object meansa real word entity such as pen, chair, table etc. Object- Oriented Programming is a methodology or paradigm to design a program using classes and objects. It simplifies the software development and maintenance by providing some concepts: • Object • Class • Inheritance • Polymorphism • Abstraction • Encapsulation 15arbabwaseer@gmail.com
  • 16.
    Object: Any entity thathas state and behavior is known as an object. For example: chair, pen, table, keyboard, bike etc. It can be physical and logical. 16arbabwaseer@gmail.com
  • 17.
    • Syntax todeclare a class: •Class • Collection of objects is called class. It is a logical entity. 17arbabwaseer@gmail.com
  • 18.
    Simple Example ofObject and Class • In this example, we have created a Student class that have two data members id and name. We are creating the object of the Student class by new keyword and printing the objects value. 18arbabwaseer@gmail.com
  • 19.
  • 20.
  • 21.
    •Polymorphism • When onetask is performed by different ways i.e. known as polymorphism. For example: to convince the customer differently, to draw something e.g. shape or rectangle etc. • In java, we use method overloading and method overriding to achieve polymorphism. • Another example can be to speak something e.g. cat speaks meaw, dog barks woof etc. •Inheritance • When one object acquires all the properties and behaviors of parent object i.e. known as inheritance. It provides code reusability. It is used to achieve runtime polymorphism. 21arbabwaseer@gmail.com
  • 22.
  • 23.
    • Abstraction • Hidinginternal details and showing functionality is known as abstraction. For example: phone call, we don't know the internal processing. • In java, we use abstract class and interface to achieve abstraction. •Encapsulation • Binding (or wrapping) code and data together into a single unit is known as encapsulation. For example: capsule, it is wrapped with different medicines. • A java class is the example of encapsulation. Java bean is the fully encapsulated class because all the data members are private here. 23arbabwaseer@gmail.com
  • 24.
  • 25.
    Advantage of OOPsover Procedure- oriented programming language • OOPs makes development and maintenance easier where as in Procedure-oriented programming language it is not easy to manage if code grows as project size grows. • OOPs provides data hiding whereas in Procedure-oriented programming language a global data can be accessed from anywhere. • OOPs provides ability to simulate real-world event much more effectively. We can provide the solution of real word problem if we are using the Object-Oriented Programming language. 25arbabwaseer@gmail.com
  • 26.
  • 27.
    •What is differencebetween object-oriented programming language and object-based programming language? • Object based programming language follows all the features of OOPs except Inheritance. JavaScript and VBScript are examples of object based programming languages. 27arbabwaseer@gmail.com