100 likes | 230 Vues
This tutorial focuses on advanced Java concepts essential for CPSC 233, covering key topics such as copy constructors, pass by value vs. pass by reference, and the usage of static members. Explore member inheritance, visibility modifiers (private, protected, public), and differences between method overriding and overloading. Understand how constructors are invoked in inheritance and analyze practical UML diagrams through code exercises. Engage with quizzes and review sessions to reinforce your understanding of these fundamental computer science principles for major study.
E N D
Introduction to Computer Science for Majors II CPSC 233, Winter 2013 Tutorial 14, Mar 27/28, 2013 CPSC 233, winter 2013
Outline • Review • Quiz CPSC 233, winter 2013
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
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? CPSC 233, winter 2013
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
UML Diagram (source code in practice1/) • 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)?
UML Diagram (source code in practice2/) • 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 2013