Interface, Subclass, and Abstract Class Review

Slides:



Advertisements
Similar presentations
UML (cont.) “The Unified Modeling Language User Guide” by G. Booch, J. Rumbaugh and I. Jacobson ● Classes ● Relationships ● Class diagrams ● Examples.
Advertisements

Week 8 Recap CSE 115 Spring Composite Revisited Once we create a composite object, it can itself refer to composites. Once we create a composite.
Inheritance Inheritance Reserved word protected Reserved word super
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
Advanced Programming in Java
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Encapsulation, Inheritance & Interfaces CSE 115 Spring 2006 February 27, March 1 & 3, 2006.
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.
1 Evan Korth New York University Inheritance and Polymorphism Professor Evan Korth New York University.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
1 Evan Korth New York University Inheritance and Polymorphism Professor Evan Korth New York University.
UML Class Diagram: class Rectangle
Chapter 10 Classes Continued
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter N - 1 Chapter 13 Polymorphism is-a relationships Interfaces.
8.1 Classes & Inheritance Inheritance Objects are created to model ‘things’ Sometimes, ‘things’ may be different, but still have many attributes.
Object Oriented Concepts. Movement toward Objects Instead of data-oriented or process-oriented Analysis, many firms are now moving to object-oriented.
UML Class Diagrams: Basic Concepts. Objects –The purpose of class modeling is to describe objects. –An object is a concept, abstraction or thing that.
Inheritance using Java
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Specialization and Inheritance Chapter 8. 8 Specialization Specialized classes inherit the properties and methods of the parent or base class. A dog is.
Chapter 3 Inheritance and Polymorphism Goals: 1.Superclasses and subclasses 2.Inheritance Hierarchy 3.Polymorphism 4.Type Compatibility 5.Abstract Classes.
8. Inheritance “Is-a” Relationship. Topics Creating Subclasses Overriding Methods Class Hierarchies Abstract Class Inheritance and GUIs The Timer Class.
Chapter 10: Introduction to Inheritance. Objectives Learn about the concept of inheritance Extend classes Override superclass methods Call constructors.
Chapter 12 Object-oriented design for more than one class.
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 – 9.4.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Inheritance and Polymorphism. Superclass and Subclass Inheritance defines a relationship between objects that share characteristics. It is a mechanism.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Inheritance and Polymorphism
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
Class Relationships Lecture Oo08 Polymorphism. References n Booch, et al, The Unified Modeling Language User Guide, Chapt 10 p.125 n Fowler & Scott, UML.
COP INTERMEDIATE JAVA Inheritance, Polymorphism, Interfaces.
Inheritance & Method Overriding BCIS 3680 Enterprise Programming.
SUBCLASSES - JAVA. The Purpose of Subclasses Class Farm String getOwner() void setOwner(String s) int getSize() void setSize(int s) Class DairyFarm String.
CSII Final Review. How many bits are in a byte? 8.
Notices Assn 2 is due tomorrow, 7pm. Moodle quiz next week – written in the lab as before. Everything up to and including today’s lecture: Big Topics are.
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.
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: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Class Inheritance Part II: Overriding and Polymorphism Corresponds with Chapter 10.
Inheritance and Polymorphism
Advanced Programming in Java
Modern Programming Tools And Techniques-I
Class Inheritance Part I
Advanced Programming in Java
Advanced Programming in Java
Sections Inheritance and Abstract Classes
Business System Development
Inheritance and Polymorphism
OBJECT ORIENTED PROGRAMMING II LECTURE 7 GEORGE KOUTSOGIANNAKIS
Week 4 Object-Oriented Programming (1): Inheritance
An Introduction to Inheritance
UML Class Diagram: class Rectangle
Chapter 10 Thinking in Objects
UML Class Diagrams: Basic Concepts
MSIS 670 Object-Oriented Software Engineering
Inheritance, Polymorphism, and Interfaces. Oh My
Advanced Programming Behnam Hatami Fall 2017.
OBJECT-ORIENTED PROGRAMMING
Advanced Java Programming
Java Programming, Second Edition
Advanced Programming in Java
Which best describes the relationship between classes and objects?
Chapter 14 Abstract Classes and Interfaces
Inheritance and Polymorphism
Agenda Inheritance Polymorphism Type compatibility Homework.
Presentation transcript:

Interface, Subclass, and Abstract Class Review Mr. Crone

True/False Interfaces can be instantiated.

True/False Interfaces can be instantiated. FALSE

True/False Interfaces can contain instance variables.

True/False Interfaces can contain instance variables. FALSE

True/False The statement below could be placed in an interface without error. public void setSide(double side){ }

True/False The statement below could be placed in an interface without error. public void setSide(double side){ } FALSE

True/False Assuming that Red is an interface, the code below will cause an error. Red r1;

True/False Assuming that Red is an interface, the code below will cause an error. Red r1; False

True/False Assuming that Car is an interface and Hybrid is an implementing class, the instantiation below will cause an error (you may assume that a default constructor for Hybrid exists). Car c = new Hybrid();

True/False Assuming that Car is an interface and Hybrid is an implementing class, the instantiation below will cause an error (you may assume that a default constructor for Hybrid exists). Car c = new Hybrid(); False

Vocabulary If more than one class implements an interface, its methods are said to be __________ ?

Vocabulary If more than one class implements an interface, its methods are said to be polymorphic.

True/False Class A implements Interface C. Class B extends Class A. Therefore, Class B also implements Interface C.

True/False Class A implements Interface C. Class B extends Class A. Therefore, Class B also implements Interface C. True

True/False Class A implements interface D. Classes B and F also implement interface D. Therefore, either B or F must be the subclass of A.

True/False Class A implements interface D. Classes B and F also implement interface D. Therefore, either B or F must be the subclass of A. False

In a UML diagram, how is the implements relationship shown?

In a UML diagram, how is the implements relationship shown In a UML diagram, how is the implements relationship shown? A dotted line connecting the interface with the implementing class.

What is the exact spelling and capitalization of the operator used to determine how an object was instantiated?

What is the exact spelling and capitalization of the operator used to determine how an object was instantiated? instanceof

Vocabulary _________is the process by which a subclass can reuse attributes and behavior defined in a superclass

Vocabulary Inheritance is the process by which a subclass can reuse attributes and behavior defined in a superclass

Vocabulary What is the vocabulary term for providing new code for a method that is already located in a superclass?

Vocabulary What is the vocabulary term for providing new code for a method that is already located in a superclass? Overriding a method

Vocabulary What is the term for using the same method name but accepting different parameters

Vocabulary What is the term for using the same method name but accepting different parameters Overloading

The UML diagram below provides an example of what type of relationship?

The UML diagram below provides an example of what type of relationship The UML diagram below provides an example of what type of relationship? Dependency

The UML Diagram below describes what type of relationship?

The UML Diagram below describes what type of relationship?

An “is-a” relationship is an informal way of describing what two relationships?

An “is-a” relationship is an informal way of describing what two relationships? Implements Extends

What is the informal way of describing the Aggregation relationship?

What is the informal way of describing the Aggregation relationship What is the informal way of describing the Aggregation relationship? “has-a”

There are two significant differences between abstract classes and concrete classes. State the two significant differences.

There are two significant differences between abstract classes and concrete classes. State the two significant differences. Abstract classes cannot be instantiated. Abstract classes can contain abstract methods.

What does UML stand for?

What does UML stand for? Unified Modeling Language

Class A implements Interfaces B and C Class A implements Interfaces B and C. Class A has two Class D objects for instance variables. Class E extends Class D. Draw the UML Diagram for the situation described above. Include the Object Class

Class Object Interface B Interface C Class A 2 Class D Class E