Object Oriented Programming
|
|
- Hollie Wells
- 5 years ago
- Views:
Transcription
1
2 Object Oriented Programming Objects self-contained working units encapsulate data and operations exist independantly of each other (functionally, they may depend) cooperate and communicate to perform a common task Classes are Object Types (abstract data types) are instantiated as Objects Inherit from other Classes form Type Hierarchies may redefine inherited behavior Polymorphically (c)schmiedecke 13 C#-2 - Classes and Objects 2
3 Classes are types are "blueprints" for objects (heap objects, indefinite scope) can form type hierarchies by inheritance Namespaces are "containers" for types (classes -- and interfaces, enumerations, structs, delegates) may be nested determine their members' fully qualified name public classes (etc.) can be used, if they are referenced i.e. their path is known to the project using is a shorthand to omit the namespace path of a classname it is not an act of import! (c)schmiedecke 13 C#-2 - Classes and Objects 3
4 The following class definitions are equivalent: using System.IO; namespace fileutils { public class FileInformation { public void PrintFileInformation(string filename) { if (File.Exists(filename)) { string fileinfo = RetrieveFileInfo(filename); //... namespace fileutils { public class FileInformation { public void PrintFileInformation(string filename) { if (System.IO.File.Exists(filename)) { string fileinfo = RetrieveFileInfo(filename); //... (c)schmiedecke 13 C#-2 - Classes and Objects 4
5 C# Constructors (Destructors) Fields Properties Indexer Events Methods Overloaded Operators Inner Types JAVA Constructors Fields Methods Inner Types (c)schmiedecke 13 C#-2 - Classes and Objects 5
6 no headers needed compiler extracts info about public members declaration order is irrelevant compiler builds name table destructors not necessary (and not recommendable) "dead" (i.e. unreferenced) objects are automatically collected by the garbage collector much easier and much safer! (c)schmiedecke 13 C#-2 - Classes and Objects 6
7 variables, instance and static should be private, for internal use only naming convention: camelcase (start with small letter) extra modifiers for constants: const (compiletime value) static const (global constant) readonly (immutable after initialization) (usually) public class Person { private char internalstatus; // cryptic on purpose private static int currentwaitingtime; public const int ID; (c)schmiedecke 13 C#-2 - Classes and Objects 7
8 restricted dynamic typing standard in functional programming best known from scripting languages, like python, ruby, in C# mainly used in Lambda Expressions type of variable open until first assignation var MyVariant; // type yet unknown MyVariant = new DateTime(); // typed fixed to DateTime (c)schmiedecke 13 C#-2 - Classes and Objects 8
9 Programming best practice in all oo programs! private fields with get and set accessors shorthand declaration in C# readonly by omitting the setter class Person { private char internalstatus; // cryptic on purpose private static int currentwaitingtime; private int id; public int Id { get { return id; set { id = value; //automatic property: public int Id { get ; set //with resticted access public int Id { get ; private set (c)schmiedecke 13 C#-2 - Classes and Objects 9
10 void methods and functions like in Java naming convention PascalCase methods can take parameters and throw and handle exceptions (without declaring them) an instance method reads or modifies "its" instance fields a static method gets ist data from parameters. public class BankAccount { private decimal Balance; private decimal DebtLimit; private decimal Transit; public void Add(decimal amount) { public void Transfer(decimal amount, BankAccount acc) { if (Balance + DebtLimit < amount) throw new BankingException(); Transit=amount; acc.add(amount); Transit=0; (c)schmiedecke 13 C#-2 - Classes and Objects 10
11 Each object has an identity a state, with characteristic features (constants) and changing features (properties) state initialization at object construction using a constructor (or direct initialization) implicit default constructor initializes to 0, false and null public class NewTime { public NewTime(int h, int, m, int s) // constr. w/ 3 params { SetTime(h, m, s); public NewTime(int h) : this(h, 0, 0){ // using constructor // initializer : this //... (c)schmiedecke 13 C#-2 - Classes and Objects 11
12 public class Time1 { private int hour; // 0-23 private int minute; // 0-59 private int second; // 0-59 public void SetTime( int h, int m, int s ) { hour = ( ( h >= 0 && h < 24 )? h : 0 ); // validate hour minute = ( ( m >= 0 && m < 60 )? m : 0 ); // validate minute second = ( ( s >= 0 && s < 60 )? s : 0 ); // validate second // convert to string in universal-time format (HH:MM:SS) public string ToUniversalString() { return string.format( "{0:D2:{1:D2:{2:D2", hour, minute, second ); // convert to string in standard-time format (H:MM:SS AM or PM) public override string ToString() { return string.format( "{0:{1:D2:{2:D2 {3", ( ( hour == 0 hour == 12 )? 12 : hour % 12 ), minute, second, ( hour < 12? "AM" : "PM" ) ); // end class Time1 // example taken from Deitel&Deitel, C# (c)schmiedecke 13 C#-2 - Classes and Objects 12
13 each time object holds a 3-member time value can be set and read as string in two formats members cannot be read or set individually for outside change of internal representation without effect to "clients" (e.g to standard unix time, millisecs since 1974) setting an inconsistent state is prevented SetTime is robust (c)schmiedecke 13 C#-2 - Classes and Objects 13
14 Write another class with a Main method inside Main, set different time values and print the output (c)schmiedecke 13 C#-2 - Classes and Objects 14
15 Use Properties insead for robustness every setter checks for validity SetTime can simply use setters use of getters and setters is implicit: Hour = h; // setter is called return string.format( "{0:D2:{1:D2:{2:D2", Hour, Minute, Second ); // getter is called (c)schmiedecke 13 C#-2 - Classes and Objects 15
16 public class Time { public int Hour { // 0-23 private get ; set { hour = ( ( h >= 0 && h < 24 )? h : 0 ); // validate hour public int Minute { // 0 59 private get ; set { minute = ( ( m >= 0 && m < 60 )? m : 0 ); // validate minute public int Second { // 0-59 private get ; set { second = ( ( s >= 0 && s < 60 )? s : 0 ); // validate second public void SetTime( int h, int m, int s ) { Hour = h; Minute = m; Second = s; // convert to string in universal time format (HH:MM:SS) public string ToUniversalString() { return string.format( "{0:D2:{1:D2:{2:D2", Hour, Minute, Second ); //... (c)schmiedecke 13 C#-2 - Classes and Objects 16
17 Overloading: "Defining another method using the same name, but different parameters, either in number or type." C# allows for constructor overloading method overloading operator overloading implicit default constructor initializes to 0, false and null overloading constructors remove implicit constructor when overloading, make sure to add a default constructor! (c)schmiedecke 13 C#-2 - Classes and Objects 17
18 Constuctor definition like a method with name of class. Constructor overloading: Define more than one constructor. Constructor initializer: reuse another constructor (rather than redundantly redifining it) using :this - body starts with calling other constructor. public class NewTime { public NewTime(int h, int, m, int s) // constr. w/ 3 params { SetTime(h, m, s); public NewTime(int h) : this(h, 0, 0){ // using constructor // initializer : this //... (c)schmiedecke 13 C#-2 - Classes and Objects 18
19 Finish defining class Time2 with all necessary constructors. Use constructor initialization wherever possible. Test it. (c)schmiedecke 13 C#-2 - Classes and Objects 19
20 Time has no overloaded constructors but public properties that should be initialized Object initilizers "invent" a constructor by calling it using the names of the properties as parameter names no need to mention all, others initialized to 0 / false / null Time MyTime = new Time(Hour=11, Minute=15, Second=0); Time YourTime = new Time(Hour=14); // all others 0 (c)schmiedecke 13 C#-2 - Classes and Objects 20
21 change your Main method so that it uses overloaded constructors object initializers (c)schmiedecke 13 C#-2 - Classes and Objects 21
22 Write a class Date which does the following: stores day, month, year (not day of the week) as properties makes sure that only valid dates can be stored provides a method public override string tostring() which returns the TURKISH way of writing a date (e.g. 26/02/2013) Test it! Hint: A year is a leap year (29 days in february) if it can be divided by 400 OR it can be divided by 4, but not by 100. Hint: If you need an array, this is how you define it: MyType[] MyArray = new MyType[200]; (c)schmiedecke 13 C#-2 - Classes and Objects 22
23 Time and Date look useful Let's make them reusable by putting them into a library: Put them into a new namespace (e.g. TimeUtilites) Create a new project of type Class Library Copy both classes into the project and build it. In your file system (or under "all files") you will find a.dll file Create a new solution right-click on it it in the sol'n explorer Choose "Add Reference" and find your.dll file Now copy one of the test progams here Add the appropriate using directive and run it. using System, using TimeUtilities; (c)schmiedecke 13 C#-2 - Classes and Objects 23
24 Our Time class does not allow us to add hours (like "postpone for 3 hours" It's a published library class, you should not change it Glue an additional method onto it public static Time AddHours( this Time tm, int hours) { Time newtime = new Time(tm.Hour, tm.minute, tm.second); newtimehour = (tm.hour + hours) % 24; return NewTime; Time mytime = new Time (22, 12, 08); mytime = mytime.addhours(3); Console.WriteLine(mytime); // 01:12:08 (c)schmiedecke 13 C#-2 - Classes and Objects 24
25 Must be static Must be members of a static class Can only access public properties and methods of the extended class. public static class TimeExtensions { public static Time AddHours( this Time tm, int hours) { Time newtime = new Time(tm.Hour, tm.minute, tm.second); newtimehour = (tm.hour + hours) % 24; return NewTime; (c)schmiedecke 13 C#-2 - Classes and Objects 25
26 Warning! A n instance method with the same signature HIDES the extension So, if later on, a similar method is added to the class or to one of ist superclasses, your extension method will no longer be called! (c)schmiedecke 13 C#-2 - Classes and Objects 26
27 none, internal accessible within assembly (=project) OR public accessible from anywhere static contains only static members abstract only for subclassing, no instantiation OR sealed subclassing prohibited OR none find contradicting combinations! (c)schmiedecke 13 C#-2 - Classes and Objects 27
28 public accessible anywhere none, internal accessible within assembly (=project) protected accessible in subclasses private accessible within class (even other instances) static member belongs to class, not instance abstract not for fields virtual method: open for polymorphic overriding override method: polymorphic overriding const field: compiletime constant readonly field: immutable after initialization (c)schmiedecke 13 C#-2 - Classes and Objects 28
29 static fields are not specific to instances the type manages them for all instances (family property) Class Windsor Chief: Queen E II Res: Buckingham P Home: Windsor C. static methods cannot access the instance use static fields, call static methods receive data via parameters create instance to call instance methods Charles William Elizabeth II static classes Kate contain only static members (c)schmiedecke 13 C#-2 - Classes and Objects 29
30 Utilities Global Constants General Computations and Conversions int age = Math.Min(myAge, yourage); string datestring = Convert.ToString(DateTime.Now); File.WriteAllText((@".\logfile.txt", logoutput, Encoding.UTF8); (c)schmiedecke 13 C#-2 - Classes and Objects 30
31 could Compute day of the week for a given Date Convert Date to other calendar Validate a Date Compute next leap year for a given Date Provide national output formats for Date All makes sense without storing a Date, i.e. without an instance state. (But it would also make sense as instance methods) static class DateUtilities { public static string DayOfTheWeek(Date date) {... public static bool IsValidDate (int day, int month, int year) { (c)schmiedecke 13 C#-2 - Classes and Objects 31
32 (c)schmiedecke 13 C#-2 - Classes and Objects 32
Object Oriented Programming
Object Oriented Programming Objects self-contained working units encapsulate data and operations exist independantly of each other (functionally, they may depend) cooperate and communicate to perform a
More informationChapter 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 informationclasses, inheritance, interfaces, polymorphism simple and structured types, generics type safeness
C# is an object oriented language very much like Java a little more modern (int is an object) much more features and add-ons (to keep experienced programmers happy) classes, inheritance, interfaces, polymorphism
More informationJava 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 informationCMSC 132: Object-Oriented Programming II
CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 4 (a): Classes & Objects Lecture Contents 2 What is a class? Class definition: Data Methods Constructors objects Static members
More informationCMSC 132: Object-Oriented Programming II
CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 4 : Classes & Objects Lecture Contents What is a class? Class definition: Data Methods Constructors Properties (set/get) objects
More informationHierarchical inheritance: Contains one base class and multiple derived classes of the same base class.
1. What is C#? C# (pronounced "C sharp") is a simple, modern, object oriented, and type safe programming language. It will immediately be familiar to C and C++ programmers. C# combines the high productivity
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 4 : Classes & Objects Lecture Contents What is a class? Class definition: Data Methods Constructors Properties (set/get) objects
More informationLecture Contents CS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 4 : Classes & Objects Lecture Contents What is a class? Class definition: Data Methods Constructors Properties (set/get) objects
More informationEEE-425 Programming Languages (2013) 1
2 Learn about class concepts How to create a class from which objects can be instantiated Learn about instance variables and methods How to declare objects How to organize your classes Learn about public
More informationObject-Oriented Programming
Object-Oriented Programming 1. What is object-oriented programming (OOP)? OOP is a technique to develop logical modules, such as classes that contain properties, methods, fields, and events. An object
More informationWeiss Chapter 1 terminology (parenthesized numbers are page numbers)
Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationObject Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming
Overview of OOP Object Oriented Programming is a programming method that combines: a) Data b) Instructions for processing that data into a self-sufficient object that can be used within a program or in
More informationZhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson
Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program
More informationObjects and Classes. Basic OO Principles. Classes in Java. Mark Allen Weiss Copyright 2000
Objects and Classes Mark Allen Weiss Copyright 2000 8/30/00 1 Basic OO Principles Objects are entities that have structure and state. Each object defines operations that may access or manipulate that state.
More informationCmSc 150 Fundamentals of Computing I. Lesson 28: Introduction to Classes and Objects in Java. 1. Classes and Objects
CmSc 150 Fundamentals of Computing I Lesson 28: Introduction to Classes and Objects in Java 1. Classes and Objects True object-oriented programming is based on defining classes that represent objects with
More informationC++ 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 informationCS304 Object Oriented Programming Final Term
1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes? Generalization (pg 29) Sub-typing
More informationChapter 6 Introduction to Defining Classes
Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of
More informationEEE-425 Programming Languages (2013) 1
2 Learn about class concepts How to create a class from which objects can be instantiated Learn about instance variables and methods How to declare objects How to organize your classes Learn about public
More informationChapter 02 Building Multitier Programs with Classes
Chapter 02 Building Multitier Programs with Classes Student: 1. 5. A method in a derived class overrides a method in the base class with the same name. 2. 11. The Get procedure in a class module is used
More informationCPS 506 Comparative Programming Languages. Programming Language
CPS 506 Comparative Programming Languages Object-Oriented Oriented Programming Language Paradigm Introduction Topics Object-Oriented Programming Design Issues for Object-Oriented Oriented Languages Support
More informationOOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.
OOPS Viva Questions 1. What is OOPS? OOPS is abbreviated as Object Oriented Programming system in which programs are considered as a collection of objects. Each object is nothing but an instance of a class.
More informationUnderstanding Inheritance and Interfaces
Chapter 8 Objectives Understanding Inheritance and Interfaces In this chapter, you will: Implement the Boat generalization/specialization class hierarchy Understand abstract and final classes and the MustInherit
More informationC++ (classes) Hwansoo Han
C++ (classes) Hwansoo Han Inheritance Relation among classes shape, rectangle, triangle, circle, shape rectangle triangle circle 2 Base Class: shape Members of a class Methods : rotate(), move(), Shape(),
More informationOBJECT 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 informationChapter 2: Java OOP I
Chapter 2: Java OOP I Yang Wang wyang AT njnet.edu.cn Outline OO Concepts Class and Objects Package Field Method Construct and Initialization Access Control OO Concepts Object Oriented Methods Object An
More informationCS304 Object Oriented Programming
1 CS304 Object Oriented Programming 1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes?
More informationChapter 2. Building Multitier Programs with Classes The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill
Chapter 2 Building Multitier Programs with Classes McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Objectives Discuss object-oriented terminology Create your own class and instantiate
More informationAbsolute C++ Walter Savitch
Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents
More informationIntroduce C# as Object Oriented programming language. Explain, tokens,
Module 2 98 Assignment 1 Introduce C# as Object Oriented programming language. Explain, tokens, lexicals and control flow constructs. 99 The C# Family Tree C Platform Independence C++ Object Orientation
More informationCompiler Errors. Flash CS4 Professional ActionScript 3.0 Language Reference. 1 of 18 9/6/2010 9:40 PM
1 of 18 9/6/2010 9:40 PM Flash CS4 Professional ActionScript 3.0 Language Reference Language Reference only Compiler Errors Home All Packages All Classes Language Elements Index Appendixes Conventions
More informationChapter 12. OOP: Creating Object-Oriented Programs The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill
Chapter 12 OOP: Creating Object-Oriented Programs McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter Objectives - 1 Use object-oriented terminology correctly Create a two-tier
More informationSoftware Development With Java CSCI
Software Development With Java CSCI-3134-01 D R. R A J S I N G H Outline Week 8 Controlling Access to Members this Reference Default and No-Argument Constructors Set and Get Methods Composition, Enumerations
More informationData Structures (list, dictionary, tuples, sets, strings)
Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 05: Inheritance and Interfaces MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Inheritance and Interfaces 2 Introduction Inheritance and Class Hierarchy Polymorphism Abstract Classes
More informationObject 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 informationProgramming II (CS300)
1 Programming II (CS300) Chapter 02: Using Objects MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Using Objects 2 Introduction to Object Oriented Programming Paradigm Objects and References Memory Management
More informationChapter 15: Object Oriented Programming
Chapter 15: Object Oriented Programming Think Java: How to Think Like a Computer Scientist 5.1.2 by Allen B. Downey How do Software Developers use OOP? Defining classes to create objects UML diagrams to
More informationCMSC 4023 Chapter 11
11. Topics The Concept of Abstraction Introduction to Data Abstraction Design Issues for Abstract Data Types Language Examples Parameterized Abstract Data Types Encapsulation Constructs Naming Encapsulations
More informationObject oriented programming. Encapsulation. Polymorphism. Inheritance OOP
OOP Object oriented programming Polymorphism Encapsulation Inheritance OOP Class concepts Classes can contain: Constants Delegates Events Fields Constructors Destructors Properties Methods Nested classes
More informationInheritance: Develop solutions by abstracting real-world object and their interaction into code to develop software solutions. Layering: Organization
Final Exam Overview: Monday, 3pm-6pm, in WLH 2005 First pages: Quiz question - No quiz of week 2 - No bit manipulation (shifting and masking) - Quizzes: week 4, 6, 8, 10 One page on C++ language features
More informationIntroduction to Programming Microsoft.NET Applications with Visual Studio 2008 (C#)
Introduction to Programming Microsoft.NET Applications with Visual Studio 2008 (C#) Course Number: 6367A Course Length: 3 Days Course Overview This three-day course will enable students to start designing
More information! Data is stored in variables. - Perhaps using arrays and structs. ! Program is a collection of functions that perform
Ch 13: Introduction to Classes 13.1 Procedural Programming! Data is stored in variables CS 2308 Spring 2013 Jill Seaman - Perhaps using arrays and structs.! Program is a collection of functions that perform
More informationDistributed Systems Recitation 1. Tamim Jabban
15-440 Distributed Systems Recitation 1 Tamim Jabban Office Hours Office 1004 Tuesday: 9:30-11:59 AM Thursday: 10:30-11:59 AM Appointment: send an e-mail Open door policy Java: Object Oriented Programming
More informationDistributed Systems Recitation 1. Tamim Jabban
15-440 Distributed Systems Recitation 1 Tamim Jabban Office Hours Office 1004 Sunday, Tuesday: 9:30-11:59 AM Appointment: send an e-mail Open door policy Java: Object Oriented Programming A programming
More informationCMSC 202 Section 010x Spring Justin Martineau, Tuesday 11:30am
CMSC 202 Section 010x Spring 2007 Computer Science II Final Exam Name: Username: Score Max Section: (check one) 0101 - Justin Martineau, Tuesday 11:30am 0102 - Sandeep Balijepalli, Thursday 11:30am 0103
More informationJAVA 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(800) Toll Free (804) Fax Introduction to Java and Enterprise Java using Eclipse IDE Duration: 5 days
Course Description This course introduces the Java programming language and how to develop Java applications using Eclipse 3.0. Students learn the syntax of the Java programming language, object-oriented
More informationSubclassing for ADTs Implementation
Object-Oriented Design Lecture 8 CS 3500 Fall 2009 (Pucella) Tuesday, Oct 6, 2009 Subclassing for ADTs Implementation An interesting use of subclassing is to implement some forms of ADTs more cleanly,
More informationIntroduction to Inheritance
Introduction to Inheritance James Brucker These slides cover only the basics of inheritance. What is Inheritance? One class incorporates all the attributes and behavior from another class -- it inherits
More informationLesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014
Lesson 10A OOP Fundamentals By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Definition Pointers vs containers Object vs primitives Constructors Methods Object class
More informationObject-Oriented Programming
- oriented - iuliana@cs.ubbcluj.ro Babes-Bolyai University 2018 1 / 56 Overview - oriented 1 2 -oriented 3 4 5 6 7 8 Static and friend elements 9 Summary 2 / 56 I - oriented was initially created by Bjarne
More informationUnit3: 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 informationObject Oriented Programming. Solved MCQs - Part 2
Object Oriented Programming Solved MCQs - Part 2 Object Oriented Programming Solved MCQs - Part 2 It is possible to declare as a friend A member function A global function A class All of the above What
More informationAn Introduction to C++
An Introduction to C++ Introduction to C++ C++ classes C++ class details To create a complex type in C In the.h file Define structs to store data Declare function prototypes The.h file serves as the interface
More information! Data is stored in variables. - Perhaps using arrays and structs. ! Program is a collection of functions that perform
Ch 13: Introduction to Classes 13.1 Procedural Programming! Data is stored in variables CS 2308 Fall 2012 Jill Seaman - Perhaps using arrays and structs.! Program is a collection of functions that perform
More informationAbstract Data Types and Encapsulation Concepts
Abstract Data Types and Encapsulation Concepts The Concept of Abstraction An abstraction is a view or representation of an entity that includes only the most significant attributes The concept of abstraction
More informationContents. 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 informationCS1004: Intro to CS in Java, Spring 2005
CS1004: Intro to CS in Java, Spring 2005 Lecture #13: Java OO cont d. Janak J Parekh janak@cs.columbia.edu Administrivia Homework due next week Problem #2 revisited Constructors, revisited Remember: a
More informationBuilding Multitier Programs with Classes
2-1 2-1 Building Multitier Programs with Classes Chapter 2 This chapter reviews object-oriented programming concepts and techniques for breaking programs into multiple tiers with multiple classes. Objectives
More informationContents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix
PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring
More informationJava: introduction to object-oriented features
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: introduction to object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer
More informationIndex. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107
A abbreviations 17 abstract class 105 abstract data types 105 abstract method 105 abstract types 105 abstraction 92, 105 access level 37 package 114 private 115 protected 115 public 115 accessors 24, 105
More informationChapter 12. OOP: Creating Object- Oriented Programs. McGraw-Hill. Copyright 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved.
Chapter 12 OOP: Creating Object- Oriented Programs McGraw-Hill Copyright 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. Objectives (1 of 2) Use object-oriented terminology correctly. Create
More informationGlossary. For Introduction to Programming Using Python By Y. Daniel Liang
Chapter 1 Glossary For Introduction to Programming Using Python By Y. Daniel Liang.py Python script file extension name. assembler A software used to translate assemblylanguage programs into machine code.
More informationDay 4. COMP1006/1406 Summer M. Jason Hinek Carleton University
Day 4 COMP1006/1406 Summer 2016 M. Jason Hinek Carleton University today s agenda assignments questions about assignment 2 a quick look back constructors signatures and overloading encapsulation / information
More information1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8
Epic Test Review 1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4 Write a line of code that outputs the phase Hello World to the console without creating a new line character. System.out.print(
More informationClass, Variable, Constructor, Object, Method Questions
Class, Variable, Constructor, Object, Method Questions http://www.wideskills.com/java-interview-questions/java-classes-andobjects-interview-questions https://www.careerride.com/java-objects-classes-methods.aspx
More informationData Abstraction. Hwansoo Han
Data Abstraction Hwansoo Han Data Abstraction Data abstraction s roots can be found in Simula67 An abstract data type (ADT) is defined In terms of the operations that it supports (i.e., that can be performed
More informationChapter 4: Writing Classes
Chapter 4: Writing Classes Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Writing Classes We've been using predefined classes. Now we will learn to write our own
More informationAnd Even More and More C++ Fundamentals of Computer Science
And Even More and More C++ Fundamentals of Computer Science Outline C++ Classes Special Members Friendship Classes are an expanded version of data structures (structs) Like structs, the hold data members
More informationIndex COPYRIGHTED MATERIAL
Index COPYRIGHTED MATERIAL Note to the Reader: Throughout this index boldfaced page numbers indicate primary discussions of a topic. Italicized page numbers indicate illustrations. A abstract classes
More informationAP Computer Science Chapter 10 Implementing and Using Classes Study Guide
AP Computer Science Chapter 10 Implementing and Using Classes Study Guide 1. A class that uses a given class X is called a client of X. 2. Private features of a class can be directly accessed only within
More informationChapter 11. Abstract Data Types and Encapsulation Concepts ISBN
Chapter 11 Abstract Data Types and Encapsulation Concepts ISBN 0-321-49362-1 Chapter 11 Topics The Concept of Abstraction Introduction to Data Abstraction Design Issues for Abstract Data Types Language
More informationObject-Oriented Programming in C# (VS 2015)
Object-Oriented Programming in C# (VS 2015) This thorough and comprehensive 5-day course is a practical introduction to programming in C#, utilizing the services provided by.net. This course emphasizes
More informationCS-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 information1 Shyam sir JAVA Notes
1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write
More information! Data is stored in variables. - Perhaps using arrays and structs. ! Program is a collection of functions that perform
Ch 13: Introduction to Classes 13.1 Procedural Programming Data is stored in variables CS 2308 Spring 2014 Jill Seaman - Perhaps using arrays and structs. Program is a collection of functions that perform
More informationComments are almost like C++
UMBC CMSC 331 Java Comments are almost like C++ The javadoc program generates HTML API documentation from the javadoc style comments in your code. /* This kind of comment can span multiple lines */ //
More informationObject-Based Programming (Deitel chapter 8)
Object-Based Programming (Deitel chapter 8) 1 Plan 2 Introduction Implementing a Time Abstract Data Type with a Class Class Scope Controlling Access to Members Referring to the Current Object s Members
More informationAnatomy of a Class Encapsulation Anatomy of a Method
Writing Classes Writing Classes We've been using predefined classes. Now we will learn to write our own classes to define objects Chapter 4 focuses on: class definitions instance data encapsulation and
More informationInheritance. 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 informationLearn C# Errata. 3-9 The Nullable Types The Assignment Operators
1 The following pages show errors from the original edition, published in July 2008, corrected in red. Future editions of this book will be printed with these corrections. We apologize for any inconvenience
More informationProblem Solving with C++
GLOBAL EDITION Problem Solving with C++ NINTH EDITION Walter Savitch Kendrick Mock Ninth Edition PROBLEM SOLVING with C++ Problem Solving with C++, Global Edition Cover Title Copyright Contents Chapter
More informationObjects and Classes: Working with the State and Behavior of Objects
Objects and Classes: Working with the State and Behavior of Objects 1 The Core Object-Oriented Programming Concepts CLASS TYPE FACTORY OBJECT DATA IDENTIFIER Classes contain data members types of variables
More informationJava. Classes 3/3/2014. Summary: Chapters 1 to 10. Java (2)
Summary: Chapters 1 to 10 Sharma Chakravarthy Information Technology Laboratory (IT Lab) Computer Science and Engineering Department The University of Texas at Arlington, Arlington, TX 76019 Email: sharma@cse.uta.edu
More information! Data is stored in variables. - Perhaps using arrays and structs. ! Program is a collection of functions that perform
Ch 13: Introduction to Classes 13.1 Procedural Programming! Data is stored in variables CS 2308 Fall 2013 Jill Seaman - Perhaps using arrays and structs.! Program is a collection of functions that perform
More informationObject Oriented Design
Object Oriented Design Lecture 3: Introduction to C++ (Continue) Examples using declarations that eliminate the need to repeat the std:: prefix 1 Examples using namespace std; enables a program to use
More information02 Features of C#, Part 1. Jerry Nixon Microsoft Developer Evangelist Daren May President & Co-founder, Crank211
02 Features of C#, Part 1 Jerry Nixon Microsoft Developer Evangelist Daren May President & Co-founder, Crank211 Module Overview Constructing Complex Types Object Interfaces and Inheritance Generics Constructing
More informationObjects and Classes. Amirishetty Anjan Kumar. November 27, Computer Science and Engineering Indian Institue of Technology Bombay
Computer Science and Engineering Indian Institue of Technology Bombay November 27, 2004 What is Object Oriented Programming? Identifying objects and assigning responsibilities to these objects. Objects
More informationPOLYMORPHISM 2 PART Abstract Classes Static and Dynamic Casting Common Programming Errors
POLYMORPHISM 2 PART Abstract Classes Static and Dynamic Casting Common Programming Errors CSC 330 OO Software Design 1 Abstract Base Classes class B { // base class virtual void m( ) =0; // pure virtual
More informationPOLYMORPHISM 2 PART. Shared Interface. Discussions. Abstract Base Classes. Abstract Base Classes and Pure Virtual Methods EXAMPLE
Abstract Base Classes POLYMORPHISM 2 PART Abstract Classes Static and Dynamic Casting Common Programming Errors class B { // base class virtual void m( ) =0; // pure virtual function class D1 : public
More informationMore C++ : Vectors, Classes, Inheritance, Templates
Vectors More C++ : Vectors,, Inheritance, Templates vectors in C++ basically arrays with enhancements indexed similarly contiguous memory some changes defined differently can be resized without explicit
More informationAgenda. Objects and classes Encapsulation and information hiding Documentation Packages
Preliminaries II 1 Agenda Objects and classes Encapsulation and information hiding Documentation Packages Inheritance Polymorphism Implementation of inheritance in Java Abstract classes Interfaces Generics
More informationhttps://asd-pa.perfplusk12.com/admin/admin_curric_maps_display.asp...
1 of 8 8/27/2014 2:15 PM Units: Teacher: ProgIIIAPCompSci, CORE Course: ProgIIIAPCompSci Year: 2012-13 Computer Systems This unit provides an introduction to the field of computer science, and covers the
More informationClasses and Objects: A Deeper Look
Classes and Objects: A Deeper Look 8 Instead of this absurd division into sexes, they ought to class people as static and dynamic. Evelyn Waugh Is it a world to hide virtues in? William Shakespeare But
More information