Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "1 Introduction to Computer Science for Majors II CPSC 233, Winter 2013 CPSC 233, winter 2013 Tutorial 14, Mar 27/28, 2013."— Presentation transcript:

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

2 Outline Review Quiz CPSC 233, winter 2013 2

3 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 2013 2

4 4

5 5

6 6 Is the toString() method considered overloading or overriding? Is the definition of the method println(), println(String), println(int), etc… considered overloading or overriding? If you have multiple constructors in the same class with different arguments, is it considered overloading or overriding?

7 Constructor Invoking The non-argument constructor automatically calls the super class constructor which calls its super class constructor up to the class object constructor If you want to call a constructor in the super class use: super(……) CPSC 233, winter 2013 7

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

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

10 Outline Review Quiz CPSC 233, winter 2013 10


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

Similar presentations


Ads by Google