COME 339 WEEK 1. Example: The Course Class 2 TestCourceRunCourse.

Slides:



Advertisements
Similar presentations
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 8 Inheritance and.
Advertisements

OOP: Inheritance By: Lamiaa Said.
1 Inheritance Chapter 9. 2 Module Outcomes To develop a subclass from a superclass through inheritance To invoke the superclass ’ s constructors and methods.
Constructors And Instantiation. Constructor Basics Every class must have a constructor Even abstract classes!! No return types Their names must exactly.
1 l Inheritance Basics l Programming with Inheritance l Dynamic Binding and Polymorphism Inheritance.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Inheritance and Polymorphism.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 9 Inheritance and.
Object Concepts in C# Class, object, attribute, method, message, instance, encapsulation, polymorphism, inheritance, association, persistence, Generalization/specialization,
1 Inheritance and Polymorphism. 2 Motivations Suppose you will define classes to model circles, rectangles, and triangles. These classes have many common.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 9 Thinking in Objects.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 11 Inheritance and Polymorphism.
MIT AITI 2002 Abstract Classes, Interfaces. Abstract Classes What is an abstract class? An abstract class is a class in which one or more methods is declared,
Inheritance. Introduction Inheritance is one of the cornerstones of object-oriented programming because it allows the creation of hierarchical classifications.
Computer Science [3] Java Programming II - Laboratory Course Lab 1 + 2: Review inheritance & abstract Review inheritance & abstractPolymorphism Faculty.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 11 Inheritance and Polymorphism.
Inheritance and Polymorphism Daniel Liang, Introduction to Java Programming.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved OBJECTS –ORIENTED PROGRAMMING.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
Inheritance - Polymorphism ITI 1121 Nour El Kadri.
Liang,Introduction to Java Programming,revised by Dai-kaiyu 1 Chapter 8 Inheritance and Polymorphism 一切皆有缘起.
28-Dec-04polymorhism.ppt1 Polymorphism. 28-Dec-04polymorhism.ppt2 signatures in any programming language, a signature is what distinguishes one function.
JAVA COURSE LESSON2 BY OMPUTER ENGINEEING ASSOCIATION.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved
Object Oriented Programming Examples: C++, Java Advantages: 1. reusibility of code 2. ability to adapt (extend) previously written code.
Java Programming Dr. Randy Kaplan. Abstract Classes and Methods.
Inheritance and Design CSIS 3701: Advanced Object Oriented Programming.
© 2007 Lawrenceville Press Slide 1 Chapter 8 Objects  A variable of a data type that is a class. Also called an instance of a class.  Stores data  Can.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 9 Inheritance and.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 10 Inheritance and.
COP3502 Programming Fundamentals for CIS Majors 1 Instructor: Parisa Rashidi.
CS 2430 Day 9. Announcements Quiz 2.1 this Friday Program 2 due this Friday at 3pm (grace date Sunday at 10pm)
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. Chapter 12 Inheritance and Class Design 1.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved COS240 O-O Languages AUBG,
1 Chapter 4 Inheritance and Polymorphism. 2 Objectives u To develop a subclass from a superclass through inheritance. u To invoke the superclass’s constructors.
AD Lecture #1 Object Oriented Programming Three Main Principles 1 Inheritance Encapsulation Polymorphism.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 11 Inheritance and Polymorphism.
1 / 41 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 5 Programming Fundamentals using Java 1.
1 Object-Oriented Programming Inheritance. 2 Superclasses and Subclasses Superclasses and Subclasses  Superclasses and subclasses Object of one class.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 11 Inheritance and Polymorphism.
Java Inheritance in Java. Inheritance Inheritance is a mechanism in which one object acquires all the properties and behaviors of parent object. The idea.
CS 112 Programming 2 Lecture 06 Inheritance & Polymorphism (1)
1 Chapter 2 Inheritance and Polymorphism. 2 Objectives u To develop a subclass from a superclass through inheritance. u To invoke the superclass’s constructors.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 10 Inheritance and Polymorphism.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Fall 2013 Chapter 10 Thinking.
Lecture 4: Object Composition, Inheritance and Polymorphism Michael Hsu CSULA.
Learning Plan 6 Java Programming Intro to Object Oriented Programming.
Staples are our staple Building upon our solution.
Modern Programming Tools And Techniques-I
Lecture 4: Object Composition, Inheritance and Polymorphism
Chapter 11 Inheritance and Polymorphism
Chapter 11 Inheritance and Polymorphism
Chapter 11 Inheritance and Polymorphism
ATS Application Programming: Java Programming
3 Fundamentals of Object-Oriented Programming
Chapter 9 Inheritance and Polymorphism
Polymorphism CT1513.
CNT 4007C Project 2 Good morning, everyone. In this class, we will have a brief look at the project 2. Project 2 is basically the same with project 1.
Chapter 9 Inheritance and Polymorphism
Object-Oriented Programming
Object Oriented Programming in JAVA
class PrintOnetoTen { public static void main(String args[]) {
Object Oriented Programming
Inheritance with Constructor
Chapter 11 Inheritance and Polymorphism
Chapter 11 Inheritance and Polymorphism Part 1
Object Oriented Programming.
Chapter 11 Inheritance and Polymorphism
Chapter 11 Inheritance and Encapsulation and Polymorphism
Chapter 11 Inheritance and Polymorphism
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
Presentation transcript:

COME 339 WEEK 1

Example: The Course Class 2 TestCourceRunCourse

Designing the Loan Class 3 TestLoanClassRunLoan

Concepts of Object Oriented Programming Three main concepts of object-oriented praogramming – Encapsulation – Inheritance – Polymorphism

Superclasses and Subclasses 5 GeometricObject1 Circle4 Rectangle1 TestCircleRectangle Run

Trace Execution 6 public class Faculty extends Employee { public static void main(String[] args) { new Faculty(); } public Faculty() { System.out.println("(4) Faculty's no-arg constructor is invoked"); } class Employee extends Person { public Employee() { this("(2) Invoke Employee’s overloaded constructor"); System.out.println("(3) Employee's no-arg constructor is invoked"); } public Employee(String s) { System.out.println(s); } class Person { public Person() { System.out.println("(1) Person's no-arg constructor is invoked"); } 1. Start from the main method animation

Trace Execution 7 public class Faculty extends Employee { public static void main(String[] args) { new Faculty(); } public Faculty() { System.out.println("(4) Faculty's no-arg constructor is invoked"); } class Employee extends Person { public Employee() { this("(2) Invoke Employee’s overloaded constructor"); System.out.println("(3) Employee's no-arg constructor is invoked"); } public Employee(String s) { System.out.println(s); } class Person { public Person() { System.out.println("(1) Person's no-arg constructor is invoked"); } 2. Invoke Faculty constructor animation

Trace Execution 8 public class Faculty extends Employee { public static void main(String[] args) { new Faculty(); } public Faculty() { System.out.println("(4) Faculty's no-arg constructor is invoked"); } class Employee extends Person { public Employee() { this("(2) Invoke Employee’s overloaded constructor"); System.out.println("(3) Employee's no-arg constructor is invoked"); } public Employee(String s) { System.out.println(s); } class Person { public Person() { System.out.println("(1) Person's no-arg constructor is invoked"); } 3. Invoke Employee’s no-arg constructor animation

Trace Execution 9 public class Faculty extends Employee { public static void main(String[] args) { new Faculty(); } public Faculty() { System.out.println("(4) Faculty's no-arg constructor is invoked"); } class Employee extends aPerson { public Employee() { this("(2) Invoke Employee’s overloaded constructor"); System.out.println("(3) Employee's no-arg constructor is invoked"); } public Employee(String s) { System.out.println(s); } class Person { public Person() { System.out.println("(1) Person's no-arg constructor is invoked"); } 4. Invoke Employee(String) constructor animation

Trace Execution 10 public class Faculty extends Employee { public static void main(String[] args) { new Faculty(); } public Faculty() { System.out.println("(4) Faculty's no-arg constructor is invoked"); } class Employee extends Person { public Employee() { this("(2) Invoke Employee’s overloaded constructor"); System.out.println("(3) Employee's no-arg constructor is invoked"); } public Employee(String s) { System.out.println(s); } class Person { public Person() { System.out.println("(1) Person's no-arg constructor is invoked"); } 5. Invoke Person() constructor animation

Trace Execution 11 public class Faculty extends Employee { public static void main(String[] args) { new Faculty(); } public Faculty() { System.out.println("(4) Faculty's no-arg constructor is invoked"); } class Employee extends Person { public Employee() { this("(2) Invoke Employee’s overloaded constructor"); System.out.println("(3) Employee's no-arg constructor is invoked"); } public Employee(String s) { System.out.println(s); } class Person { public Person() { System.out.println("(1) Person's no-arg constructor is invoked"); } 6. Execute println animation

Trace Execution 12 public class Faculty extends Employee { public static void main(String[] args) { new Faculty(); } public Faculty() { System.out.println("(4) Faculty's no-arg constructor is invoked"); } }a class Employee extends Person { public Employee() { this("(2) Invoke Employee’s overloaded constructor"); System.out.println("(3) Employee's no-arg constructor is invoked"); } public Employee(String s) { System.out.println(s); } class Person { public Person() { System.out.println("(1) Person's no-arg constructor is invoked"); } 7. Execute println animation

Trace Execution 13 public class Faculty extends Employee { public static void main(String[] args) { new Faculty(); } public Faculty() { System.out.println("(4) Faculty's no-arg constructor is invoked"); } class Employee extends Person { public Employee() { this("(2) Invoke Employee’s overloaded constructor"); System.out.println("(3) Employee's no-arg constructor is invoked"); } public Employee(String s) { System.out.println(s); } class Person { public Person() { System.out.println("(1) Person's no-arg constructor is invoked"); } 8. Execute println animation

Trace Execution 14 public class Faculty extends Employee { public static void main(String[] args) { new Faculty(); } public Faculty() { System.out.println("(4) Faculty's no-arg constructor is invoked"); } class Employee extends Person {a public Employee() { this("(2) Invoke Employee’s overloaded constructor"); System.out.println("(3) Employee's no-arg constructor is invoked"); } public Employee(String s) { System.out.println(s); } class Person { public Person() { System.out.println("(1) Person's no-arg constructor is invoked"); } 9. Execute println animation