Introducing PA6 – The Last one

Slides:



Advertisements
Similar presentations
Final and Abstract Classes
Advertisements

Lecture 5: Interfaces.
OO Programming in Java Objectives for today: Overriding the toString() method Polymorphism & Dynamic Binding Interfaces Packages and Class Path.
CS 116 OBJECT ORIENTED PROGRAMMING II LECTURE 9 GEORGE KOUTSOGIANNAKIS Copyright: 2015 Illinois Institute of Technology/George Koutsogiannakis 1.
Inheritance Java permits you to use your user defined classes to create programs using inheritance.
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
Encapsulation, Inheritance & Interfaces CSE 115 Spring 2006 February 27, March 1 & 3, 2006.
Slides prepared by Rose Williams, Binghamton University Chapter 13 Interfaces and Inner Classes.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Java: Early Objects Third Edition by Tony Gaddis Chapter.
8.1 Classes & Inheritance Inheritance Objects are created to model ‘things’ Sometimes, ‘things’ may be different, but still have many attributes.
Inheritance and Polymorphism CS351 – Programming Paradigms.
Inheritance Chapter 11.
Abstract classes and Interfaces. Abstract classes.
Inheritance in the Java programming language J. W. Rider.
Chapter 3 Inheritance and Polymorphism Goals: 1.Superclasses and subclasses 2.Inheritance Hierarchy 3.Polymorphism 4.Type Compatibility 5.Abstract Classes.
Chapter Outline What inheritance is Calling the superclass constructor Overriding superclass methods Protected members Chains of inheritance The Object.
11-1 Chapter.9 Classes & Objects: Inheritance –What Is Inheritance? –Calling the Superclass Constructor –Overriding Superclass Methods –Protected Members.
Chapter Topics Chapter 10 discusses the following main topics:
Abstract Classes and Interfaces 8. Building Applications Using C#/ Session 8 © Aptech Ltd. Objectives  Define and describe abstract classes  Explain.
More on Inheritance Chapter 11 Continued. Reminders Overloading – different signatures Overriding – same signatures Preventing overriding – use final.
11-2  What Is Inheritance?  Calling the Superclass Constructor  Overriding Superclass Methods  Protected Members  Chains of Inheritance  The Object.
Inheritance and Access Control CS 162 (Summer 2009)
MIT AITI 2004 – Lecture 13 Abstract Classes and Interfaces.
Chapter 10: Introduction to Inheritance. Objectives Learn about the concept of inheritance Extend classes Override superclass methods Call constructors.
I NTRODUCTION TO PROGRAMMING Starting Out with Java: From Control Structures through Objects.
Java Programming, Second Edition Chapter Twelve Advanced Inheritance Concepts.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Programming in java Packages Access Protection Importing packages Java program structure Interfaces Why interface Defining interface Accessing impln thru.
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
© 2010 Pearson Addison-Wesley. All rights reserved. AN INTRODUCTION TO INHERITANCE.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
Recap Introduction to Inheritance Inheritance in C++ IS-A Relationship Polymorphism in Inheritance Classes in Inheritance Visibility Rules Constructor.
POLYMORPHISM Chapter 6. Chapter Polymorphism  Polymorphism concept  Abstract classes and methods  Method overriding  Concrete sub classes and.
COP INTERMEDIATE JAVA Inheritance, Polymorphism, Interfaces.
Inheritance & Method Overriding BCIS 3680 Enterprise Programming.
CS 116 Object Oriented Programming II Lecture 9 Acknowledgement: Contains materials provided by George Koutsogiannakis and Matt Bauer.
Classes in C++ By: Mr. Jacobs. Objectives  Explore the implications of permitting programmers to define their own data types and then present C++ mechanism.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Java Programming Fifth Edition Chapter 9 Introduction to Inheritance.
Java Interfaces CS 21a: Introduction to Computing I Department of Information Systems and Computer Science Ateneo de Manila University (see Chapter 9 of.
Chapter 11 Polymorphism. Contents I. Polymorphism 1. Polymorphism 2. Polymorphism and Dynamic Binding 3. The “is-a” Relationship Does Not Work in Reverse.
Inheritance and Polymorphism
Sections Inheritance and Abstract Classes
Inheritance-Basics.
Final and Abstract Classes
Polymorphism, Abstract Classes & Interfaces
Inheritance and Polymorphism
by Tony Gaddis and Godfrey Muganda
Interfaces.
An introduction to inheritance
Starting Out with Java: From Control Structures through Objects
Chapter 19 Generics Dr. Clincy - Lecture.
OBJECT ORIENTED PROGRAMMING II LECTURE 8 GEORGE KOUTSOGIANNAKIS
Java Programming Language
Chapter 9: Polymorphism and Inheritance
Week 6 Object-Oriented Programming (2): Polymorphism
Interfaces.
Polymorphism, Abstract Classes & Interfaces
OBJECT ORIENTED PROGRAMMING II LECTURE 9 GEORGE KOUTSOGIANNAKIS
CSE 1030: Implementing GUI Mark Shtern.
9: POLYMORPHISM Programming Technique II (SCSJ1023) Jumail Bin Taliba
Java Programming, Second Edition
Object-Oriented Programming: Inheritance and Polymorphism
Unit 1 PreLab11 Objective: We will define an abstract class and look at how it is used. Closing Task: We will write a class that extends an abstract class.
Inheritance.
Chapter 14 Abstract Classes and Interfaces
Chapter 11 Inheritance and Polymorphism Part 1
Final and Abstract Classes
Lecture 0311 – Polymorphism
Static Binding Static binding chooses the function in the class of the base class pointer, ignoring any versions in the class of the object actually.
Presentation transcript:

Introducing PA6 – The Last one And a review of PA5 design and followup from Lab 17.

PA5

LAB 17 – Inheritance Revisited From Friday's lab: Run the HRV3.java program. Are the results correct (consistent with the first version)? Why or why not? How might you solve this problem? In other words, can you design a solution that will enable us to pay all employees at once? Introducing abstract classes: Abstract classes are like a class family template. Think about Employee. Do we ever instantiate employees?  See demo using the HR application.

Abstract Classes An abstract class cannot be instantiated, but other classes are derived from it. An Abstract class serves as a superclass for other classes. The abstract class represents the generic or abstract form of all the classes that are derived from it. A class becomes abstract when you place the abstract key word in the class definition. public abstract class ClassName

Abstract Methods An abstract method has no body and must be overridden in a subclass. An abstract method is a method that appears in a superclass, but expects to be overridden in a subclass. An abstract method has only a header and no body. AccessSpecifier abstract ReturnType MethodName(ParameterList); Example: Student.java, CompSciStudent.java, CompSciStudentDemo.java

Abstract Methods Notice that the key word abstract appears in the header, and that the header ends with a semicolon. public abstract void setValue(int value); Any class that contains an abstract method is automatically abstract. If a subclass fails to override an abstract method, a compiler error will result. Abstract methods are used to ensure that a subclass implements the method.

Interfaces An interface is similar to an abstract class that has all abstract methods. It cannot be instantiated, and all of the methods listed in an interface must be written elsewhere. The purpose of an interface is to specify behavior for other classes. An interface looks similar to a class, except: the keyword interface is used instead of the keyword class, and the methods that are specified in an interface have no bodies, only headers that are terminated by semicolons.

Interfaces The general format of an interface definition: public interface InterfaceName { (Method headers...) } All methods specified by an interface are public by default. A class can implement one or more interfaces.

And now for PA6 http://w3.cs.jmu.edu/arch/crs/cs159/pa/pa6-accounts.php