Java 程式設計入門. 講師 : 陳昭源 CSIE, NTU September 28, 2005

Size: px
Start display at page:

Download "Java 程式設計入門. 講師 : 陳昭源 CSIE, NTU September 28, 2005"

Transcription

1 Java 程式設計入門 講師 : 陳昭源 CSIE, NTU September 28, 2005

2 Outline Floating Point & Decimal Numbers Inheritance Polymorphism Design Principles Abstract Exercise Interface September 28, 2005 Page 2

3 Floating Point & Decimal Numbers IEEE 754 Floating Point Representation Floating Point (32 bits) s exponent 指數 mantissa 尾數 1 8 bits 23 bits Double Precision Floating Point (64 bits) s exponent 指數 mantissa 尾數 1 11 bits 52 bits 小數部份使用二進位 ( 以 2 為底數 ) 來表示 ; 最高位對應 2-1, 次高位元對應 2-2, 依此類推 許多數字無法使用精確表示 September 28, 2005 Page 3

4 Floating Point & Decimal Numbers BigDecimal 類別 (java.math) constructor BigDecimal(double val) vs. BigDecimal(String val) methods compareto(bigdecimal val) vs. equals(object x) HW05 bonus: 精準度控制 小數部分最多採記到公厘以下兩位, 四捨五入 參考 BigDecimalSample.java September 28, 2005 Page 4

5 Inheritance Inheritance 語法 : class ClassName extends BaseClass Each class in Java inherits from Java standard root class, Object, without any explicitly claim. Each class in Java can inherit from only one (non-interface) base class. Base Class (SuperClass): 基底類別 父類別 Derived Class (Subclass): 衍生類別 子類別 The derived class would inherit all accessible members in the base class, including variables and methods. The new class is like that old class. Note: Constructors can t be inherited! September 28, 2005 Page 5

6 Polymorphism Upcasting The derived class is a type (superset) of the existing (base) class. Objects of the derived class is also of the base class. The base class is always more general than the derived class. Thus, casting from a derived type to a base type is called upcasting, and it is safe. The compiler allow upcasting without any explicit casts or other special notation. Why Upcasting? Polymorphism talk only to the base class (upcasting) instead of many derived classes (overloading) Example: SamplePoly.java September 28, 2005 Page 6

7 Polymprphism How does Java do polymorphism? Late Binding Method-call Binding Connecting a method call to the method body is called binding. Early binding: binding before the program is run. Late binding: binding at run time, based on the object type. All method bindings in Java use late binding unless the method is static or final/private. September 28, 2005 Page 7

8 Design Principles Principle #01 Favor Composition Over Inheritance! One of the clearest ways to determine whether you should use composition or inheritance is to ask whether you will ever need to upcast from your new class to the base class. If you must upcast, then inheritance is necessary; otherwise, you should look closely at whether you need inheritance. September 28, 2005 Page 8

9 Design Principles Advantages/Disadvantages of Composition Advantages Objects are accessed solely through its interface. Black-box reuse, and good encapsulation. Fewer implementation dependencies, and each class is focused on just one task. The composition can be defined dynamically at run-time. Disadvantages Systems tend to have more objects. Interfaces must be carefully defined in order to use many different objects as composition blocks. September 28, 2005 Page 9

10 Design Principles Advantages/Disadvantages of Inheritance Advantages New implementation is easy, and easy to modify/extend the implementation being reused. Disadvantages Breaks encapsulation White-box reuse Subclasses may have to be changed if the implementation of the superclass changes. Implementations inherited from superclasses can not be changed at run-time September 28, 2005 Page 10

11 Design Principles Principle #02 Program to an Interface, not an Implementation! More flexible, but design complexity increases. Principle #03 Software Entities Should be Open for Extension, yet Closed for Modification! Add new code to extend the behavior of the system, but not to modify the existing code. How to do? Polymorphism Inheritance Abstract/Interface September 28, 2005 Page 11

12 Abstract Shape draw() erase() Circle draw() erase() Rectangle draw() erase() Triangle draw() erase() September 28, 2005 Page 12

13 Abstract Abstract Class common interface for all subclasses derived from it Objects of this class have no meaning! Abstract Methods An incomplete method only has the declaration and no method body. A class with one or more abstract methods should be qualified as abstract, but an abstract class may not have any abstract methods. Classes inherit from an abstract class must implement all abstract classes in the base class, or they are also abstract. September 28, 2005 Page 13

14 Abstract Class Declaration AccessLevel abstract/final class ClassName extends SuperClass implements Interface { ClassBody } Method Declaration AccessLevel static abstract/final ReturnType MethodName(ParameterList) { MethodBody } September 28, 2005 Page 14

15 Exercise 參閱 Exercise.java 使用抽象類別 Shapes, 完成 Rect 與 Tri 類別 使用 upcasting 概念, 完成 showdetails method September 28, 2005 Page 15

16 Interface Wind void play() void adjust() Woodwind void play() void adjust() Instrument void play() void adjust() Percussion void play() void adjust() Brass void play() void adjust() Stringed void play() void adjust() September 28, 2005 Page 16

17 Interface Interface a pure abstract class, a protocol between classes to establish the form for a class method names, argument lists, and return types but no method bodies Create an Interface 語法 :interface InterfaceName All methods in an interface are public even if they are not specified explicitly. September 28, 2005 Page 17

18 Interface Interface Use an Interface 語法 :class ClassName implements Iface01, Iface02, One class can implement as many interfaces as you want. Each interface, like the base class, is an independent type you can upcast to. If you want to create an object of a class which implements some interfaces, this class should provide all method definitions. September 28, 2005 Page 18

19 Interface The Core Reason to Use Interfaces to be able to upcast to more than one base type! If you know something is going to be a base class, your first choice should be to make it an interface, and only if you re forced to have method definitions or member variables should you change to an abstract class, or if necessary a concrete class. September 28, 2005 Page 19

Polymorphism. Object Orientated Programming in Java. Benjamin Kenwright

Polymorphism. Object Orientated Programming in Java. Benjamin Kenwright Polymorphism Object Orientated Programming in Java Benjamin Kenwright Quizzes/Labs Every single person should have done Quiz 00 Introduction Quiz 01 - Java Basics Every single person should have at least

More information

PC Link Mode. Terminate PC Link? Esc. [GO]/[Esc] - - [GO]/[Esc] 轉接座未放滿. Make auto accord with socket mounted? [GO]/[Esc] Copy to SSD E0000

PC Link Mode. Terminate PC Link? Esc. [GO]/[Esc] - - [GO]/[Esc] 轉接座未放滿. Make auto accord with socket mounted? [GO]/[Esc] Copy to SSD E0000 Start SU-6808 EMMC Programmer V.0bd7 [ ]Link PC / [ ]Menu [ ] >.Select project.make new project.engineer mode.reset counter 5.Link to PC [ ] PC disconnected PC connected Select project SEM0G9C_A.prj Terminate

More information

JAVA Programming Language Homework V: Overall Review

JAVA Programming Language Homework V: Overall Review JAVA Programming Language Homework V: Overall Review ID: Name: 1. Given the following Java code: [5 points] 1. public class SimpleCalc { 2. public int value; 3. public void calculate(){ value = value +

More information

Software Engineering

Software Engineering Software Engineering CSC 331/631 - Spring 2018 Object-Oriented Design Principles Paul Pauca April 10 Design Principles DP1. Identify aspects of the application that vary and separate them from what stays

More information

第九章結構化查詢語言 SQL - 資料定義語言 (DDL) 資料庫系統設計理論李紹綸著

第九章結構化查詢語言 SQL - 資料定義語言 (DDL) 資料庫系統設計理論李紹綸著 第九章結構化查詢語言 SQL - 資料定義語言 (DDL) 資料庫系統設計理論李紹綸著 SQL 的資料定義語言 本章內容 建立資料表 修改資料表 刪除資料表 FOREIGN KEY 外鍵條件約束與資料表關聯性 2 資料定義語言可分為下列三種 : SQL 的資料定義語言 CREATE TABLE 指令 : 用來建立一個基底關聯表, 和設定關聯表相關的完整性限制 CREATE VIEW 指令 : 用來建立一個視界,

More information

Object Oriented Programming. Java-Lecture 11 Polymorphism

Object Oriented Programming. Java-Lecture 11 Polymorphism Object Oriented Programming Java-Lecture 11 Polymorphism Abstract Classes and Methods There will be a situation where you want to develop a design of a class which is common to many classes. Abstract class

More information

Problem: Given a vector of pointers to Shape objects, print the area of each of the shape.

Problem: Given a vector of pointers to Shape objects, print the area of each of the shape. Problem: Given a vector of pointers to Shape objects, print the area of each of the shape. 1 Problem: Given a vector of pointers to Shape objects, sort the shape objects by areas in decreasing order. Std++sort:

More information

Upcasting. Taking an object reference and treating it as a reference to its base type is called upcasting.

Upcasting. Taking an object reference and treating it as a reference to its base type is called upcasting. 7. Polymorphism 1 Upcasting Taking an object reference and treating it as a reference to its base type is called upcasting. class Instrument { public void play () { public class Wind extends Instrument

More information

Java Class Design. Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding

Java Class Design. Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding Java Class Design Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding eugeny.berkunsky@gmail.com http://www.berkut.mk.ua Objectives Implement encapsulation Implement inheritance

More information

Chapter 2 (Part 2) Instructions: Language of the Computer

Chapter 2 (Part 2) Instructions: Language of the Computer Chapter 2 (Part 2) Instructions: Language of the Computer 陳瑞奇 (J.C. Chen) 亞洲大學資訊工程學系 Adapted from class notes by Prof. C.T. King, NTHU, Prof. M.J. Irwin, PSU and Prof. D. Patterson, UCB 1 2.6 Logical Operations

More information

Chapter 4 (Part IV) The Processor: Datapath and Control (Parallelism and ILP)

Chapter 4 (Part IV) The Processor: Datapath and Control (Parallelism and ILP) Chapter 4 (Part IV) The Processor: Datapath and Control (Parallelism and ILP) 陳瑞奇 (J.C. Chen) 亞洲大學資訊工程學系 Adapted from class notes by Prof. M.J. Irwin, PSU and Prof. D. Patterson, UCB 4.10 Instruction-Level

More information

Inheritance and object compatibility

Inheritance and object compatibility Inheritance and object compatibility Object type compatibility An instance of a subclass can be used instead of an instance of the superclass, but not the other way around Examples: reference/pointer can

More information

Introduction to inheritance

Introduction to inheritance C++ Inheritance and Polymorphism CSIE Department, NTUT Woei-Kae Chen 1 Introduction to inheritance Inheritance Derived class inherits data members and member functions from base class Single inheritance

More information

Java Object Oriented Design. CSC207 Fall 2014

Java Object Oriented Design. CSC207 Fall 2014 Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code

More information

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++

More information

C B A B B C C C C A B B A B C D A D D A A B D C C D D A B D A D C D B D A C A B

C B A B B C C C C A B B A B C D A D D A A B D C C D D A B D A D C D B D A C A B 高雄市立右昌國中 106 學年度第二學期第二次段考三年級考科答案 國文科 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. C B D C A C B A D B 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. D C B A D C A B D B 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. C B D C B B C

More information

Software Paradigms (Lesson 3) Object-Oriented Paradigm (2)

Software Paradigms (Lesson 3) Object-Oriented Paradigm (2) Software Paradigms (Lesson 3) Object-Oriented Paradigm (2) Table of Contents 1 Reusing Classes... 2 1.1 Composition... 2 1.2 Inheritance... 4 1.2.1 Extending Classes... 5 1.2.2 Method Overriding... 7 1.2.3

More information

OBJECT ORİENTATİON ENCAPSULATİON

OBJECT ORİENTATİON ENCAPSULATİON OBJECT ORİENTATİON Software development can be seen as a modeling activity. The first step in the software development is the modeling of the problem we are trying to solve and building the conceptual

More information

Java 程式設計基礎班 (7) 莊坤達台大電信所網路資料庫研究室. Java I/O. Class 7 1. Class 7 2

Java 程式設計基礎班 (7) 莊坤達台大電信所網路資料庫研究室. Java I/O.   Class 7 1. Class 7 2 Java 程式設計基礎班 (7) 莊坤達台大電信所網路資料庫研究室 Email: doug@arbor.ee.ntu.edu.tw Class 7 1 回顧 Java I/O Class 7 2 Java Data Structure 動態資料結構 Grow and shrink at execution time Several types Linked lists Stacks Queues Binary

More information

Chapter 7. Digital Arithmetic and Arithmetic Circuits. Signed/Unsigned Binary Numbers

Chapter 7. Digital Arithmetic and Arithmetic Circuits. Signed/Unsigned Binary Numbers Chapter 7 Digital Arithmetic and Arithmetic Circuits Signed/Unsigned Binary Numbers Signed Binary Number: A binary number of fixed length whose sign (+/ ) is represented by one bit (usually MSB) and its

More information

9: Polymorphism. OOP = abstraction + inheritance + polymorphism

9: Polymorphism. OOP = abstraction + inheritance + polymorphism 9: Polymorphism OOP = abstraction + inheritance + polymorphism 1 Substitutability A Circle Shape A Square A Line 2 Extensibility A Circle Shape A Square A Line A Triangle 3 Interface & Implementation Shape

More information

Figure 1 Microsoft Visio

Figure 1 Microsoft Visio Pattern-Oriented Software Design (Fall 2013) Homework #1 (Due: 09/25/2013) 1. Introduction Entity relation (ER) diagrams are graphical representations of data models of relation databases. In the Unified

More information

Java 程式設計基礎班 (7) 劉根豪台大電機所網路資料庫研究室. Java I/O. Class 7 1. Class 7

Java 程式設計基礎班 (7) 劉根豪台大電機所網路資料庫研究室. Java I/O.   Class 7 1. Class 7 Java 程式設計基礎班 (7) 劉根豪台大電機所網路資料庫研究室 Email: kenliu@arbor.ee.ntu.edu.tw 1 回顧 Java I/O 2 1 Java Data Structure 動態資料結構 執行的時候可以動態變大或縮小 類型 Linked lists Stacks Queues Binary trees 3 自我參考類別 (self-referential classes)

More information

UAK1-C01 USB Interface Data Encryption Lock USB 資料加密鎖. Specifications for Approval

UAK1-C01 USB Interface Data Encryption Lock USB 資料加密鎖. Specifications for Approval Product Definition C-MING Product Semi-finished Product OEM/ODM Product Component USB Interface Data Encryption Lock USB 資料加密鎖 Specifications for Approval Approval Manager Issued By Revision History Revision

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 20, 2014 Abstract

More information

SSL VPN User Manual (SSL VPN 連線使用手冊 )

SSL VPN User Manual (SSL VPN 連線使用手冊 ) SSL VPN User Manual (SSL VPN 連線使用手冊 ) 目錄 前言 (Preface) 1. ACMICPC 2018 VPN 連線說明 -- Pulse Secure for Windows ( 中文版 ):... 2 2. ACMICPC 2018 VPN 連線說明 -- Pulse Secure for Linux ( 中文版 )... 7 3. ACMICPC 2018

More information

Inheritance, polymorphism, interfaces

Inheritance, polymorphism, interfaces Inheritance, polymorphism, interfaces "is-a" relationship Similar things (sharing same set of attributes / operations): a group / concept Similar groups (sharing a subset of attributes / operations): a

More information

CS-202 Introduction to Object Oriented Programming

CS-202 Introduction to Object Oriented Programming CS-202 Introduction to Object Oriented Programming California State University, Los Angeles Computer Science Department Lecture III Inheritance and Polymorphism Introduction to Inheritance Introduction

More information

微處理機系統 吳俊興高雄大學資訊工程學系. February 21, What are microprocessors (µp)? What are the topics of this course? Why to take this course?

微處理機系統 吳俊興高雄大學資訊工程學系. February 21, What are microprocessors (µp)? What are the topics of this course? Why to take this course? 微處理機系統 吳俊興高雄大學資訊工程學系 February 21, 2005 processor, central processing unit (CPU) A silicon chip which forms the core of a microcomputer The heart of the microprocessor-based computer system Concept of what

More information

QUIZ. Write the following for the class Bar: Default constructor Constructor Copy-constructor Overloaded assignment oper. Is a destructor needed?

QUIZ. Write the following for the class Bar: Default constructor Constructor Copy-constructor Overloaded assignment oper. Is a destructor needed? QUIZ Write the following for the class Bar: Default constructor Constructor Copy-constructor Overloaded assignment oper. Is a destructor needed? Or Foo(x), depending on how we want the initialization

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 21, 2013 Abstract

More information

7: Polymorphism. Interface & Implementation. Hands-on Java Seminar 2000 Bruce Eckel page 1. A Circle.

7: Polymorphism. Interface & Implementation. Hands-on Java Seminar 2000 Bruce Eckel  page 1. A Circle. Chart 7: Polymorphism A Circle A Square A Line Substitutability 1 A Circle A Square A Line A Triangle Extensibility 2 Interface & Implementation Establishes a common interface Circle Square Line Implementations

More information

CLAD 考前準備 與 LabVIEW 小技巧

CLAD 考前準備 與 LabVIEW 小技巧 CLAD 考前準備 與 LabVIEW 小技巧 NI 技術行銷工程師 柯璟銘 (Jimmy Ko) jimmy.ko@ni.com LabVIEW 認證 Certified LabVIEW Associate Developer (LabVIEW 基礎認證 ) Certified LabVIEW Associate Developer LabVIEW 全球認證 40 題 (37 題單選,3 題複選

More information

Information System Design (IT60105)

Information System Design (IT60105) Information System Design (IT60105) Lecture 26 Object-Oriented System Testing Lecture #23 Procedural vs OO paradigms Why not Traditional Testing? Issues Methodology 2 Procedural Vs OO p Procedural Vs OO

More information

David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation

David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Chapter Six: Transforming Data Models into Database Designs 6-1 Chapter Objectives To understand how to transform

More information

Inheritance and Polymorphism

Inheritance and Polymorphism Object Oriented Programming Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. Al-Azhar University Website: eaymanelshenawy.wordpress.com Email : eaymanelshenawy@azhar.edu.eg

More information

Lecture 36: Cloning. Last time: Today: 1. Object 2. Polymorphism and abstract methods 3. Upcasting / downcasting

Lecture 36: Cloning. Last time: Today: 1. Object 2. Polymorphism and abstract methods 3. Upcasting / downcasting Lecture 36: Cloning Last time: 1. Object 2. Polymorphism and abstract methods 3. Upcasting / downcasting Today: 1. Project #7 assigned 2. equals reconsidered 3. Copying and cloning 4. Composition 11/27/2006

More information

Inheritance, Polymorphism, and Interfaces

Inheritance, Polymorphism, and Interfaces Inheritance, Polymorphism, and Interfaces Chapter 8 Inheritance Basics (ch.8 idea) Inheritance allows programmer to define a general superclass with certain properties (methods, fields/member variables)

More information

港專單一登入系統 (SSO) 讓本校的同學, 全日制及兼職老師只要一個登入帳戶, 便可同時使用由本校提供的網上系統及服務, 包括 Blackboard 網上學習平台, 港專電郵服務, 圖書館電子資料庫及其他教學行政系統.

港專單一登入系統 (SSO) 讓本校的同學, 全日制及兼職老師只要一個登入帳戶, 便可同時使用由本校提供的網上系統及服務, 包括 Blackboard 網上學習平台, 港專電郵服務, 圖書館電子資料庫及其他教學行政系統. 港專單一登入系統 (SSO) 讓本校的同學, 全日制及兼職老師只要一個登入帳戶, 便可同時使用由本校提供的網上系統及服務, 包括 Blackboard 網上學習平台, 港專電郵服務, 圖書館電子資料庫及其他教學行政系統. 港專單一登入網站網址 http://portal.hkct.edu.hk (HKCT 之教職員, 學生 ) http://portal.ctihe.edu.hk (CTIHE 之教職員,

More information

What is Polymorphism? Quotes from Deitel & Deitel s. Why polymorphism? How? How? Polymorphism Part 1

What is Polymorphism? Quotes from Deitel & Deitel s. Why polymorphism? How? How? Polymorphism Part 1 Polymorphism Part 1 What is Polymorphism? Polymorphism refers to a programming language s ability to process objects differently depending on their data type or class. Number person real complex kid adult

More information

購票流程說明 How To purchase The Ticket?

購票流程說明 How To purchase The Ticket? 購票流程說明 How To purchase The Ticket? 步驟 1: 點選 登入 Click 登入 Login (You have to login before purchasing.) 步驟 2: 若已是會員請填寫會員帳號 密碼, 點選 登入 若非會員請點選 註冊 If you are the member of PB+, Please login. If not, please register.

More information

C++ Important Questions with Answers

C++ Important Questions with Answers 1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children

More information

Object Orientated Analysis and Design. Benjamin Kenwright

Object Orientated Analysis and Design. Benjamin Kenwright Notation Part 2 Object Orientated Analysis and Design Benjamin Kenwright Outline Review What do we mean by Notation and UML? Types of UML View Continue UML Diagram Types Conclusion and Discussion Summary

More information

CST242 Object-Oriented Programming Page 1

CST242 Object-Oriented Programming Page 1 CST4 Object-Oriented Programming Page 4 5 6 67 67 7 8 89 89 9 0 0 0 Objected-Oriented Programming: Objected-Oriented CST4 Programming: CST4 ) Programmers should create systems that ) are easily extensible

More information

購票流程說明 How To purchase The Ticket?

購票流程說明 How To purchase The Ticket? 購票流程說明 How To purchase The Ticket? 步驟 1: 已是會員請點選 登入, 選擇 2016 WTA 臺灣公開賽 Taiwan Open tickets Step1:If You are the member, please Click 登入 Click to the column: 2016 WTA 臺灣公開賽 Taiwan Open tickets Click 登入

More information

Announcement. Agenda 7/31/2008. Polymorphism, Dynamic Binding and Interface. The class will continue on Tuesday, 12 th August

Announcement. Agenda 7/31/2008. Polymorphism, Dynamic Binding and Interface. The class will continue on Tuesday, 12 th August Polymorphism, Dynamic Binding and Interface 2 4 pm Thursday 7/31/2008 @JD2211 1 Announcement Next week is off The class will continue on Tuesday, 12 th August 2 Agenda Review Inheritance Abstract Array

More information

Polymorphism Part 1 1

Polymorphism Part 1 1 Polymorphism Part 1 1 What is Polymorphism? Polymorphism refers to a programming language s ability to process objects differently depending on their data type or class. Number person real complex kid

More information

COS226 - Spring 2018 Class Meeting # 13 March 26, 2018 Inheritance & Polymorphism

COS226 - Spring 2018 Class Meeting # 13 March 26, 2018 Inheritance & Polymorphism COS226 - Spring 2018 Class Meeting # 13 March 26, 2018 Inheritance & Polymorphism Ibrahim Albluwi Composition A GuitarString has a RingBuffer. A MarkovModel has a Symbol Table. A Symbol Table has a Binary

More information

EZCast Docking Station

EZCast Docking Station EZCast Docking Station Quick Start Guide Rev. 2.00 Introduction Thanks for choosing EZCast! The EZCast Docking Station contains the cutting-edge EZCast technology, and firmware upgrade will be provided

More information

Chapter 14 Abstract Classes and Interfaces

Chapter 14 Abstract Classes and Interfaces Chapter 14 Abstract Classes and Interfaces 1 What is abstract class? Abstract class is just like other class, but it marks with abstract keyword. In abstract class, methods that we want to be overridden

More information

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance Contents Topic 04 - Inheritance I. Classes, Superclasses, and Subclasses - Inheritance Hierarchies Controlling Access to Members (public, no modifier, private, protected) Calling constructors of superclass

More information

Chapter 7. Signed/Unsigned Binary Numbers. Digital Arithmetic and Arithmetic Circuits. Unsigned Binary Arithmetic. Basic Rules (Unsigned)

Chapter 7. Signed/Unsigned Binary Numbers. Digital Arithmetic and Arithmetic Circuits. Unsigned Binary Arithmetic. Basic Rules (Unsigned) Chapter 7 Digital rithmetic and rithmetic Circuits igned/unsigned inary Numbers igned inary Number: binary number of fixed length whose sign (+/ ) is represented by one bit (usually M) and its magnitude

More information

Object-Oriented Programming

Object-Oriented Programming iuliana@cs.ubbcluj.ro Babes-Bolyai University 2018 1 / 40 Overview 1 2 3 4 5 2 / 40 Primary OOP features ion: separating an object s specification from its implementation. Encapsulation: grouping related

More information

Object-Oriented Concepts and Design Principles

Object-Oriented Concepts and Design Principles Object-Oriented Concepts and Design Principles Signature Specifying an object operation or method involves declaring its name, the objects it takes as parameters and its return value. Known as an operation

More information

Inheritance. OOP components. Another Example. Is a Vs Has a. Virtual Destructor rule. Virtual Functions 4/13/2017

Inheritance. OOP components. Another Example. Is a Vs Has a. Virtual Destructor rule. Virtual Functions 4/13/2017 OOP components For : COP 3330. Object oriented Programming (Using C++) http://www.compgeom.com/~piyush/teach/3330 Data Abstraction Information Hiding, ADTs Encapsulation Type Extensibility Operator Overloading

More information

全面強化電路設計與模擬驗證. Addi Lin / Graser 2 / Sep / 2016

全面強化電路設計與模擬驗證. Addi Lin / Graser 2 / Sep / 2016 全面強化電路設計與模擬驗證 Addi Lin / Graser 2 / Sep / 2016 Agenda OrCAD Design Solution OrCAD Capture 功能應用 OrCAD Capture CIS 介紹 OrCAD PSpice 模擬與驗證 OrCAD Design Solution Powerful and Widely Used Design Solution Front-to-Back

More information

Polymorphism and Interfaces. CGS 3416 Spring 2018

Polymorphism and Interfaces. CGS 3416 Spring 2018 Polymorphism and Interfaces CGS 3416 Spring 2018 Polymorphism and Dynamic Binding If a piece of code is designed to work with an object of type X, it will also work with an object of a class type that

More information

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 43 Dynamic Binding (Polymorphism): Part III Welcome to Module

More information

Inheritance and Interfaces

Inheritance and Interfaces Inheritance and Interfaces Object Orientated Programming in Java Benjamin Kenwright Outline Review What is Inheritance? Why we need Inheritance? Syntax, Formatting,.. What is an Interface? Today s Practical

More information

Abstract Classes. Abstract Classes a and Interfaces. Class Shape Hierarchy. Problem AND Requirements. Abstract Classes.

Abstract Classes. Abstract Classes a and Interfaces. Class Shape Hierarchy. Problem AND Requirements. Abstract Classes. a and Interfaces Class Shape Hierarchy Consider the following class hierarchy Shape Circle Square Problem AND Requirements Suppose that in order to exploit polymorphism, we specify that 2-D objects must

More information

CH. 2 OBJECT-ORIENTED PROGRAMMING

CH. 2 OBJECT-ORIENTED PROGRAMMING CH. 2 OBJECT-ORIENTED PROGRAMMING ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN JAVA, GOODRICH, TAMASSIA AND GOLDWASSER (WILEY 2016) OBJECT-ORIENTED

More information

INHERITANCE & POLYMORPHISM. INTRODUCTION IB DP Computer science Standard Level ICS3U. INTRODUCTION IB DP Computer science Standard Level ICS3U

INHERITANCE & POLYMORPHISM. INTRODUCTION IB DP Computer science Standard Level ICS3U. INTRODUCTION IB DP Computer science Standard Level ICS3U C A N A D I A N I N T E R N A T I O N A L S C H O O L O F H O N G K O N G INHERITANCE & POLYMORPHISM P2 LESSON 12 P2 LESSON 12.1 INTRODUCTION inheritance: OOP allows a programmer to define new classes

More information

COMP200 INHERITANCE. OOP using Java, from slides by Shayan Javed

COMP200 INHERITANCE. OOP using Java, from slides by Shayan Javed 1 1 COMP200 INHERITANCE OOP using Java, from slides by Shayan Javed 2 Inheritance Derive new classes (subclass) from existing ones (superclass). Only the Object class (java.lang) has no superclass Every

More information

Object Oriented Software Design II

Object Oriented Software Design II Object Oriented Software Design II Inheritance Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 29, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February

More information

SPI 功能使用方法 Application Note

SPI 功能使用方法 Application Note 1 適用產品 :SM59R16A2 / SM59R08A2 2 SPI 使用概述 : SPI 通信使用 4 個引腳, 分別為 SPI_: 當 master 時資料輸出 ; 當 slave 時資料輸入 SPI_: 當 master 時資料輸入 ; 當 slave 時資料輸出 SPI_SCK: SPI 的時脈信號由 master 主控產生 ; 資料 ( 輸出及輸入 ) 和時脈同步 SPI_SS: 此引腳功能唯有當作

More information

香港中文大學學生會計算機科學系會 圖書清單

香港中文大學學生會計算機科學系會 圖書清單 香港中文大學學生會計算機科學系會 圖書清單 100 Theory 120 CGI 140 Visual Basic 160 Other Programming Book 101 Program budgeting and benefit-cost analysis 102 Introduction to Algorithms 103 Introduction to Algorithms 104 Data

More information

Programming in C# Inheritance and Polymorphism

Programming in C# Inheritance and Polymorphism Programming in C# Inheritance and Polymorphism C# Classes Classes are used to accomplish: Modularity: Scope for global (static) methods Blueprints for generating objects or instances: Per instance data

More information

More on Inheritance. Interfaces & Abstract Classes

More on Inheritance. Interfaces & Abstract Classes More on Inheritance Interfaces & Abstract Classes Java interfaces A Java interface is used to specify minimal functionality that a client requires of a server. A Java interface contains: method specifications

More information

Object Oriented Software Design II

Object Oriented Software Design II Object Oriented Software Design II Inheritance Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 29, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February

More information

Unit3: Java in the large. Prepared by: Dr. Abdallah Mohamed, AOU-KW

Unit3: Java in the large. Prepared by: Dr. Abdallah Mohamed, AOU-KW Prepared by: Dr. Abdallah Mohamed, AOU-KW 1 1. Introduction 2. Objects and classes 3. Information hiding 4. Constructors 5. Some examples of Java classes 6. Inheritance revisited 7. The class hierarchy

More information

JAVA MOCK TEST JAVA MOCK TEST II

JAVA MOCK TEST JAVA MOCK TEST II http://www.tutorialspoint.com JAVA MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to Java Framework. You can download these sample mock tests at your

More information

IT101. Inheritance, Encapsulation, Polymorphism and Constructors

IT101. Inheritance, Encapsulation, Polymorphism and Constructors IT101 Inheritance, Encapsulation, Polymorphism and Constructors OOP Advantages and Concepts What are OOP s claims to fame? Better suited for team development Facilitates utilizing and creating reusable

More information

Polymorphism. Miri Ben-Nissan (Kopel) Miri Kopel, Bar-Ilan University

Polymorphism. Miri Ben-Nissan (Kopel) Miri Kopel, Bar-Ilan University Polymorphism Miri Ben-Nissan (Kopel) 1 Shape Triangle Rectangle Circle int main( ) Shape* p = GetShape( ); p->draw( ); Shape* GetShape( ) choose randomly which shape to send back For example: Shape* p

More information

STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes

STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes Java Curriculum for AP Computer Science, Student Lesson A20 1 STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes INTRODUCTION:

More information

25. Interfaces. Java. Summer 2008 Instructor: Dr. Masoud Yaghini

25. Interfaces. Java. Summer 2008 Instructor: Dr. Masoud Yaghini 25. Interfaces Java Summer 2008 Instructor: Dr. Masoud Yaghini Outline Definition The Comparable Interface Interfaces vs. Abstract Classes Creating Custom Interfaces References Definition Definition Sometimes

More information

Department of Computer Science and Engineering National Sun Yat-sen University Data Structures - Final Exam., Jan. 9, 2017

Department of Computer Science and Engineering National Sun Yat-sen University Data Structures - Final Exam., Jan. 9, 2017 Department of Computer Science and Engineering National Sun Yat-sen University Data Structures - Final Exam., Jan. 9, 2017 1. Multiple choices (There may be zero or more correct answers. If there is no

More information

Preamble Ethernet packet Data FCS

Preamble Ethernet packet Data FCS Preamble Ethernet. packet Data FCS Destination Address Source Address EtherType Data ::: Preamble. bytes. Destination Address. bytes. The address(es) are specified for a unicast, multicast (subgroup),

More information

Inheritance. OOP: Inheritance 1

Inheritance. OOP: Inheritance 1 Inheritance Reuse Extension and intension Class specialization and class extension Inheritance The protected keyword revisited Inheritance and methods Method redefinition An widely used inheritance example

More information

Polymorphism and Inheritance

Polymorphism and Inheritance Walter Savitch Frank M. Carrano Polymorphism and Inheritance Chapter 8 Objectives Describe polymorphism and inheritance in general Define interfaces to specify methods Describe dynamic binding Define and

More information

Oxford isolution. 下載及安裝指南 Download and Installation Guide

Oxford isolution. 下載及安裝指南 Download and Installation Guide Oxford isolution 下載及安裝指南 Download and Installation Guide 系統要求 個人電腦 Microsoft Windows 10 (Mobile 除外 ) Microsoft Windows 8 (RT 除外 ) 或 Microsoft Windows 7 (SP1 或更新版本 ) ( 網上下載 : http://eresources.oupchina.com.hk/oxfordisolution/download/index.html)

More information

1.00 Lecture 13. Inheritance

1.00 Lecture 13. Inheritance 1.00 Lecture 13 Inheritance Reading for next time: Big Java: sections 10.5-10.6 Inheritance Inheritance allows you to write new classes based on existing (super or base) classes Inherit super class methods

More information

BTC, EMPREX Wireless Keybaord +Mouse + USB dongle. 6309URF III Quick Installation Guide

BTC, EMPREX Wireless Keybaord +Mouse + USB dongle. 6309URF III Quick Installation Guide BTC, EMPREX 6309URF III Quick Installation Guide Hardware Installation 1. Plug the dongle receiver connector into your available USB port on PC. 2. Make sure the batteries of the keyboard and mouse are

More information

EZCast Wire User s Manual

EZCast Wire User s Manual EZCast Wire User s Manual Rev. 2.01 Introduction Thanks for choosing EZCast! The EZCast Wire contains the cutting-edge EZCast technology, and firmware upgrade will be provided accordingly in order to compatible

More information

Introduction to C++ Introduction to C++ Dr Alex Martin 2013 Slide 1

Introduction to C++ Introduction to C++ Dr Alex Martin 2013 Slide 1 Introduction to C++ Introduction to C++ Dr Alex Martin 2013 Slide 1 Inheritance Consider a new type Square. Following how we declarations for the Rectangle and Circle classes we could declare it as follows:

More information

Relationships Between Real Things CSE 143. Common Relationship Patterns. Employee. Supervisor

Relationships Between Real Things CSE 143. Common Relationship Patterns. Employee. Supervisor CSE 143 Object & Class Relationships Inheritance Reading: Ch. 9, 14 Relationships Between Real Things Man walks dog Dog strains at leash Dog wears collar Man wears hat Girl feeds dog Girl watches dog Dog

More information

8. Polymorphism and Inheritance

8. Polymorphism and Inheritance 8. Polymorphism and Inheritance Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich http://seal.ifi.uzh.ch/info1 Objectives Describe polymorphism and inheritance in general Define interfaces

More information

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia Object Oriented Programming in Java Jaanus Pöial, PhD Tallinn, Estonia Motivation for Object Oriented Programming Decrease complexity (use layers of abstraction, interfaces, modularity,...) Reuse existing

More information

What are the characteristics of Object Oriented programming language?

What are the characteristics of Object Oriented programming language? What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is

More information

CSSE 220 Day 15. Inheritance. Check out DiscountSubclasses from SVN

CSSE 220 Day 15. Inheritance. Check out DiscountSubclasses from SVN CSSE 220 Day 15 Inheritance Check out DiscountSubclasses from SVN Discount Subclasses Work in pairs First look at my solution and understand how it works Then draw a UML diagram of it DiscountSubclasses

More information

桌上電腦及筆記本電腦安裝 Acrobat Reader 應用程式

桌上電腦及筆記本電腦安裝 Acrobat Reader 應用程式 On a desktop or notebook computer Installing Acrobat Reader to read the course materials The Course Guide, study units and other course materials are provided in PDF format, but to read them you need a

More information

EZCast Wire. User s Manual. Rev. 2.00

EZCast Wire. User s Manual. Rev. 2.00 EZCast Wire User s Manual Rev. 2.00 Introduction Thanks for choosing EZCast! The EZCast Wire contains the cutting-edge EZCast technology, and firmware upgrade will be provided accordingly in order to compatible

More information

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach. CMSC 131: Chapter 28 Final Review: What you learned this semester The Big Picture Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach. Java

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 12 Thomas Wies New York University Review Last lecture Modules Outline Classes Encapsulation and Inheritance Initialization and Finalization Dynamic

More information

1. Write two major differences between Object-oriented programming and procedural programming?

1. Write two major differences between Object-oriented programming and procedural programming? 1. Write two major differences between Object-oriented programming and procedural programming? A procedural program is written as a list of instructions, telling the computer, step-by-step, what to do:

More information

The notice regarding Participation Ways of our global distributor video conference on Feb. 5.

The notice regarding Participation Ways of our global distributor video conference on Feb. 5. The notice regarding Participation Ways of our global distributor video conference on Feb. 5. On Feb.5, 2010 Los Angeles time, between 5:00 PM - 7:00 PM, we will convene an important global distributor

More information

Java Inheritance. Written by John Bell for CS 342, Spring Based on chapter 6 of Learning Java by Niemeyer & Leuck, and other sources.

Java Inheritance. Written by John Bell for CS 342, Spring Based on chapter 6 of Learning Java by Niemeyer & Leuck, and other sources. Java Inheritance Written by John Bell for CS 342, Spring 2018 Based on chapter 6 of Learning Java by Niemeyer & Leuck, and other sources. Review Which of the following is true? A. Java classes may either

More information

What is Inheritance?

What is Inheritance? Inheritance 1 Agenda What is and Why Inheritance? How to derive a sub-class? Object class Constructor calling chain super keyword Overriding methods (most important) Hiding methods Hiding fields Type casting

More information

The major elements of the object-oriented model

The major elements of the object-oriented model The major elements of the object-oriented model Abstraction Encapsulation Inheritance Modularity Suggested Reading: Bruce Eckel, Thinking in Java (Fourth Edition) Reusing Classes Hierarchy 2 An abstraction

More information

Chapter 5 Object-Oriented Programming

Chapter 5 Object-Oriented Programming Chapter 5 Object-Oriented Programming Develop code that implements tight encapsulation, loose coupling, and high cohesion Develop code that demonstrates the use of polymorphism Develop code that declares

More information