Abstract Classes Page 197-205.

Slides:



Advertisements
Similar presentations
METHOD OVERRIDING 1.Sub class can override the methods defined by the super class. 2.Overridden Methods in the sub classes should have same name, same.
Advertisements

Inheritance Java permits you to use your user defined classes to create programs using inheritance.
SE-1020 Dr. Mark L. Hornick 1 Inheritance and Polymorphism: Abstract Classes The “not quite” classes.
Chapter 10: Introduction to Inheritance
Advanced Programming in Java
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Department of computer science N. Harika. Inheritance Inheritance is a fundamental Object Oriented concept A class can be defined as a "subclass" of another.
Inheritance The objectives of this chapter are: To explore the concept and implications of inheritance Polymorphism To define the syntax of inheritance.
Abstract Classes. Lecture Objectives To learn about abstract classes To understand how to inherit abstract classes To understand how to override abstract.
1 Lecture 3 Inheritance. 2 A class that is inherited is called superclass The class that inherits is called subclass A subclass is a specialized version.
CSE 115 Week 10 March , Announcements March 21 – Lab 7 Q & A in lecture March 21 – Lab 7 Q & A in lecture March 26 – Exam 7 March 26 – Exam.
8.1 Classes & Inheritance Inheritance Objects are created to model ‘things’ Sometimes, ‘things’ may be different, but still have many attributes.
Chapter 7 - Generalization/Specialization and Inheritance1 Chapter 7 Generalization/Specialization and Inheritance.
9/4/2015Abstract classes & Interface1 Object Oriented Design and Programming II Chapter 10 Abstract classes and Interfaces.
Inheritance using Java
Polymorphism & Interfaces
CISC6795: Spring Object-Oriented Programming: Polymorphism.
Inheritance. Introduction Inheritance is one of the cornerstones of object-oriented programming because it allows the creation of hierarchical classifications.
Mark Fontenot CSE Honors Principles of Computer Science I Note Set 14.
AP Computer Science A – Healdsburg High School 1 Interfaces, Abstract Classes and the DanceStudio - Similarities and Differences between Abstact Classes.
OOP: Encapsulation,Abstraction & Polymorphism. What is Encapsulation Described as a protective barrier that prevents the code and data being randomly.
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.
Abstract Classes. Review PA – 3 Design Considerations /Web/CS239/programs/pa3/draft.php ?harrisnlCS239
C# G 1 CSC 298 Object Oriented Programming Part 2.
Java Programming Dr. Randy Kaplan. Abstract Classes and Methods.
Abstract Classes and Interfaces 5-Dec-15. Abstract methods You can declare an object without defining it: Person p; Similarly, you can declare a method.
Inheritance Inheritance is the process of extending the functionality of a class by defining a new class that inherit,all the features of extending class.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
CS 210 Introduction to OO Design August 24, 2006
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
COP INTERMEDIATE JAVA Inheritance, Polymorphism, Interfaces.
JAVA ACCESS MODIFIERS. Access Modifiers Access modifiers control which classes may use a feature. A classes features are: - The class itself - Its member.
1 Inheritance One of the goals of object oriented programming is code reuse. Inheritance is one mechanism for accomplishing code reuse. It allows us to.
Lecture 10 – Polymorphism Nancy Harris with additional slides Professor Adams from Lewis & Bernstein.
Inheritance a subclass extends the functionality of a superclass a subclass inherits all the functionality of a superclass don't reinvent the wheel – "stand.
Java Programming Fifth Edition Chapter 9 Introduction to Inheritance.
Coming up A quick word about abstract How a class interfaces
Polymorphism in Methods
Advanced Programming in Java
Advanced Programming in Java
Sections Inheritance and Abstract Classes
OOP: Encapsulation &Abstraction
Abstract Classes and Interfaces
Overriding Method.
Interface, Subclass, and Abstract Class Review
Inheritance and Polymorphism
One class is an extension of another.
Types of Programming Languages
UML Class Diagram: class Rectangle
Object Oriented Programming
Lecture 14 - Abstract Classes
Chapter 10 Thinking in Objects
Inheritance, Polymorphism, and Interfaces. Oh My
One class is an extension of another.
Abstract Classes.
Abstract Classes AKEEL AHMED.
Interfaces.
Lecture 14- Abstract Classes
CSE 1030: Implementing GUI Mark Shtern.
METHOD OVERRIDING in JAVA
Inheritance, Superclasses, Subclasses
Java – Inheritance.
Inheritance Inheritance is a fundamental Object Oriented concept
Java Inheritance.
Advanced Programming in Java
Interfaces and Abstract Classes
Fundaments of Game Design
Chapter 9 Carrano Chapter 10 Small Java
Chapter 14 Abstract Classes and Interfaces
Inheritance and Polymorphism
Presentation transcript:

Abstract Classes Page 197-205

Page 198 Animal Inheritance Tree Good basis for the structure Page 199 – New wolf; New Hippo from Animal class. Can we create a new animal object from the animal class????

Page 200 What does a new Animal () object look like?? What would the instance variables be? Some classes just should NOT be instantiated Certain classes are created ONLY to be SuperClasses; ONLY to be inherited from There is a simple way to prevent a class from being instantiated

Abstract Marking the class as “abstract” Abstract class Canine extends Animal When designing your inheritance structure, you must decide which classes are abstract and which are concrete. Concrete classes are those that are specific enough to be instantiated. A concrete class means it’s OK to make objects of that type

Abstract – cont’d An abstract class has virtually no use, no value, no purpose in life, unless it is extended With an abstract class, the guys doing the work at runtime are instances of a subclass of your abstract class. Look at Java API for examples - JComponent

Page 202 Look at illustration – top of page 202. Abstract Methods You can mark methods abstract, too An abstract class means the class must be extended An abstract method means the method must be overridden. An abstract method has no body. End with ;

Abstract Methods – cont’d If you declare an abstract method, you MUST mark the class abstract as well. You can’t have an abstract method in a non-abstract class. You MUST implement all abstract methods Implementing an abstract method is just like overriding a method Abstract methods – no body – exist only for polymorphism First concrete class in the inheritance tree must implement all abstract methods.