1 Introduction to Computer Science for Majors II CPSC 233, Winter 2013 CPSC 233, winter 2013 Tutorial 14, Mar 27/28, 2013.

Slides:



Advertisements
Similar presentations
1 Inheritance Classes and Subclasses Or Extending a Class.
Advertisements

Module 8 “Polymorphism and Inheritance”. Outline Understanding Inheritance Inheritance Diagrams Constructors in Derived Classes Type Compatibility Polymorphism.
1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
CS 211 Inheritance AAA.
CS 106 Introduction to Computer Science I 04 / 11 / 2008 Instructor: Michael Eckmann.
Inheritance Inheritance Reserved word protected Reserved word super
Inheritance Polymorphism Briana B. Morrison CSE 1302C Spring 2010.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 8.1 – 8.5.
CS 106 Introduction to Computer Science I 04 / 16 / 2010 Instructor: Michael Eckmann.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
CS 106 Introduction to Computer Science I 04 / 21 / 2010 Instructor: Michael Eckmann.
CS102--Object Oriented Programming Review 1: Chapter 1 – Chapter 7 Copyright © 2008 Xiaoyan Li.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Computer Science I Inheritance Professor Evan Korth New York University.
Inheritance. © 2004 Pearson Addison-Wesley. All rights reserved 8-2 Inheritance Inheritance is a fundamental object-oriented design technique used to.
Chapter 10: Inheritance 1. Inheritance  Inheritance allows a software developer to derive a new class from an existing one  The existing class is called.
CS 106 Introduction to Computer Science I 04 / 13 / 2007 Friday the 13 th Instructor: Michael Eckmann.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Chapter 8 More Object Concepts
Inheritance and Class Hierarchies Ellen Walker CPSC 201 Data Structures Hiram College.
 Computer Science 1MD3 Introduction to Programming Michael Liut Ming Quan Fu Brandon.
CS212: Object Oriented Analysis and Design Lecture 15: Inheritance in C++ -II.
RIT Computer Science Dept. Goals l Inheritance l Modifiers: private, public, protected l Polymorphism.
OOP: Encapsulation,Abstraction & Polymorphism. What is Encapsulation Described as a protective barrier that prevents the code and data being randomly.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
CS442: ADVANCED PROGRAMMING USING JAVA Lab 6: Classes and objects Computer Science Department.
Inheritance Chapter 10 Programs built from objects/instances of classes An O.O. approach – build on earlier work. Use classes in library and ones you have.
Outline Creating Subclasses Overriding Methods Class Hierarchies Visibility Designing for Inheritance Inheritance and GUIs The Timer Class Copyright ©
8. Inheritance “Is-a” Relationship. Topics Creating Subclasses Overriding Methods Class Hierarchies Abstract Class Inheritance and GUIs The Timer Class.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Inheritance. Inheritance is a fundamental object-oriented design technique used to create and organize reusable classes Chapter 8 focuses on: deriving.
1 Introduction to Computer Science for Majors II CPSC 233, Winter 2013 CPSC 233, winter 2013 Tutorial 14, Mar 27/28, 2013.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Inheritance Objectives: Creating new classes from existing classes The protected modifier Creating class hierarchies Abstract classes Indirect visibility.
 Computer Science 1MD3 Introduction to Programming Michael Liut Ming Quan Fu Brandon.
Chapter 10: Introduction to Inheritance. Objectives Learn about the concept of inheritance Extend classes Override superclass methods Call constructors.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
CS 2430 Day 9. Announcements Quiz 2.1 this Friday Program 2 due this Friday at 3pm (grace date Sunday at 10pm)
Coming up: Inheritance
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 – 9.4.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
Inherited Classes in Java CSCI 392 Ch 6 in O’Reilly Adapted from Dannelly.
Software Development Introduction
CPRG 215 Introduction to Object-Oriented Programming with Java Module 3- Introduction to Object Oriented Programming concepts Topic 3.4 Constructors, Overloading,
November 27, 2001Lecture 231  Previous Lecture: Parameter passing Method overloading  Today’s Lecture: Introduction to inheritance Class diagrams and.
Java Software Solutions Lewis and Loftus Chapter 8 Copyright 1997 by John Lewis and William Loftus. All rights reserved. 1 Inheritance -- Introduction.
1 Introduction to Computer Science for Majors II CPSC 233, Winter 2013 CPSC 233, winter 2013 Tutorial 7, Feb 6/7, 2013.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Outline Creating Subclasses Overriding Methods Class Hierarchies Inheritance.
CPS120: Introduction to Computer Science Lecture 16A Object-Oriented Concepts.
Java Programming Fifth Edition Chapter 9 Introduction to Inheritance.
Review for Test2. Scope 8 problems, 60 points. 1 Bonus problem (5 points) Coverage: – Test 1 coverage – Exception Handling, Switch Statement – Array of.
Introduction to Object-oriented Programming
Inheritance.
Class Inheritance Part I
University Of Karachi Department Of Computer Science
Objects as a programming concept
Advanced Programming in Java
An Introduction to Inheritance
Road Map Inheritance Class hierarchy Overriding methods Constructors
CSC 113 Tutorial QUIZ I.
Inheritance, Polymorphism, and Interfaces. Oh My
Inherited Classes in Java
Advanced Programming Behnam Hatami Fall 2017.
Java Programming, Second Edition
Eighth step for Learning C++ Programming
C++ Programming CLASS This pointer Static Class Friend Class
Final and Abstract Classes
Unit-1 Introduction to Java
Haidong Xue Summer 2011, at GSU
Presentation transcript:

1 Introduction to Computer Science for Majors II CPSC 233, Winter 2013 CPSC 233, winter 2013 Tutorial 14, Mar 27/28, 2013

Outline Review Quiz CPSC 233, winter

Key Concepts Advanced Java Copy constructor Pass by value Pass by reference Static members Inheritance Private, protected, public Member inheritance Method overriding v.s method overloading Invoking of the constructors CPSC 233, winter

4 UML Diagram (source code in practice1/) Parent - secret:int # familySecret:int + num:int + Parent() + method() + update() + toString():String Child1 - num1:int # num2:int + count:int + Child1() + method() + toString():String Child2 - num1:int # num2:int + Child2() + Child2(obj:Child2) + update() + update(n:int) + update(obj:Child1) + toString():String Answer the following questions based on the given program What are the data members that Child1 inherits from the superclass? What are the methods that Child1 inherits from the superclass? Identify method overriding in this program Identify method overloading in this program What is the output of the program (see Driver.java)?

5 UML Diagram (source code in practice2/) GrandParent - secret:int # familySecret:int + num:int + GrandParent() + method() + update() + toString():String Child1 - num1:int + count:int + Child1() + Child1(obj:Child1) + method() + update(obj:Child1) + toString():String Parent - num1:int # num2:int + Parent() + update() + update(n:int) + toString():String Answer the following questions based on the given program What are the data members that Child1 inherits from the superclass(es)? What are the methods that Child1 inherits from the superclass(es)? What are the data members that Parent inherits from the superclass? What are the methods that Parent inherits from the superclass? Identify method overriding in this program Identify method overloading in this program What is the output of the program (see Driver.java)?

Outline Review Quiz CPSC 233, winter