Transcript
Page 1: Tutorial  14,  Mar  27 /28,  2013

CPSC 233, winter 20131

Introduction to Computer Science for

Majors II

CPSC 233, Winter 2013

Tutorial 14, Mar 27/28, 2013

Page 2: Tutorial  14,  Mar  27 /28,  2013

2

OutlineReview

Quiz

CPSC 233, winter 2013

Page 3: Tutorial  14,  Mar  27 /28,  2013

Key ConceptsAdvanced Java

Copy constructorPass by valuePass by referenceStatic members

InheritancePrivate, protected, publicMember inheritanceMethod overriding v.s method overloading Invoking of the constructors

CPSC 233, winter 2013 2

Page 4: Tutorial  14,  Mar  27 /28,  2013

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)?

Page 5: Tutorial  14,  Mar  27 /28,  2013

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)?

Page 6: Tutorial  14,  Mar  27 /28,  2013

6

OutlineReview

Quiz

CPSC 233, winter 2013