The Basics. Concepts of Class and Object

Size: px
Start display at page:

Download "The Basics. Concepts of Class and Object"

Transcription

1 Web Programming Week 11 COSC2453-SP2, 2011 OO- Part I 1 2 What are we covering now? The Basics Concepts of class and objects, How to write a class in PHP? Constructors, Visibility Modifiers, Abstract classes, Inheritance, Object Interfaces, Overloading, Polymorphism and other concepts The basics of OO Concepts of Class and Object 3 4

2 Objects and Classes An object represents an abstraction or thing with a crisp boundary for the problem at hand. eg, a car, a car fleet, a client. An object contains: data: capturing attributes and relationships with other objects (also called data members or variables), and methods for creating, accessing, transforming the data A class is a (design) template for an object (data + methods). For instance Car is a class. My car, the car QPD764 are objects (instances of the class Car) Objects are instantiated at runtime from their classes and communicate via messages Object and Real world The real-world objects share two characteristics: They all have state and behaviour. For example, dogs have state (name, color, breed, hungry) and behaviour (barking, fetching, and wagging tail). Bicycles have state (current gear, current pedal cadence, two wheels, number of gears) and behaviour (braking, accelerating, slowing down, changing gears). 5 6 What do objects consist of? The following illustration is a common visual representation of a software object (a bicycle modelled as a software object): Methods (behaviour) Variables (state) Representation of an object Methods surround and hide the object's nucleus from other objects in the program. Packaging an object's variables within the protective custody of its methods is called encapsulation. This conceptual picture of an object - a nucleus of variables packaged within a protective membrane of methods - is an ideal representation of an object and is the ideal that designers of object-oriented systems strive for. 7 8

3 Encapsulation Encapsulating related variables and methods into a neat software bundle is a simple yet powerful idea that provides two primary benefits to software developers: Modularity: The source code for an object can be written and maintained independently of the source code for other objects. Also, an object can be easily passed around in the system. You can give your bicycle to someone else, and it will still work. Information hiding: An object has a public interface that other objects can use to communicate with it. The object can maintain private information and methods that can be changed at any time without affecting the other objects that depend on it. You don't need to understand the gear mechanism on your bike to use it. Objects do talk A single object alone is generally not very useful. Instead, an object usually appears as a component of a larger program or application that contains many other objects. Through the interaction of these objects, programmers achieve higher-order functionality and more complex behaviour. Your bicycle hanging from a hook in the garage is just a bunch of titanium alloy and rubber; by itself, the bicycle is incapable of any activity. The bicycle is useful only when another object (you) interacts with it (pedal). Software objects interact and communicate with each other by sending messages to each other. When object A wants object B to perform one of B's methods, object A sends a message to object B 9 10 Messages Sometimes, the receiving object needs more information so that it knows exactly what to do; for example, when you want to change gears on your bicycle, you have to indicate which gear you want. This information is passed along with the message as parameters. The next figure shows the three components that comprise a message: 1.The object to which the message is addressed (YourBicycle) 2.The name of the method to perform (changegears) 3.Any parameters needed by the method (lowergear) Looking inside a class In object-oriented software, it's also possible to have many objects of the same kind that share characteristics: rectangles, employee records, video clips, and so on. Like the bicycle manufacturers, you can take advantage of the fact that objects of the same kind are similar and you can create a blueprint for those objects. A class is a blueprint, or prototype, that defines the variables and the methods common to all objects of a certain kind

4 More about a class The class for our bicycle example would declare the instance variables necessary to contain the current gear, the current cadence, and so on, for each bicycle object. The class would also declare and provide implementations for the instance methods that allow the rider to change gears, brake, and change the pedaling cadence, as shown in the next figure. Class and an Instance After you've created the bicycle class, you can create any number of bicycle objects from the class. When you create an instance of a class, the system allocates enough memory for the object and all its instance variables. Each instance gets its own copy of all the instance variables defined in the class Class versus Object You probably noticed that the illustrations of objects and classes look very similar. The difference between classes and objects is often the source of some confusion. In the real world, it's obvious that classes are not themselves the objects they describe: A blueprint of a bicycle is not a bicycle. However, it's a little more difficult to differentiate classes and objects in software. This is partially because software objects are merely electronic models of real-world objects or abstract concepts in the first place. But it's also because the term "object" is sometimes used to refer to both classes and instances. An interlude Before we go on to write some code in PHP, let us have a look at a real life example - A banking system. to understand how classes are born. If you understand the concept, the code writing is very simple 15 16

5 A Real World Example: A Bank system The Bank stores data about its customers. A customer has a name, a customer number, a password and up to 5 accounts. An account is identified by an account number and has a balance. A customer can perform withdrawals, deposits and queries on his/her account balance. How to discover classes (and their relationships)? How to discover attributes (for a class)? How to discover methods (for a class)? Discovering classes A concrete entity, eg. Student, Course An abstract concept, eg. Shape, Comparable Rule of thumb: look for nouns in the problem specs Relationship: Association? Composition? Inheritance? What are these? Discuss it with your lecturer/tutor. We will elaborate upon these later on. How many instances of one class are there in the other? stores owns Bank Customer Account 1 1..M Discovering Relationships 1 1..M Bank Customer Account customers : Customer [ ] accounts : Account [ ] Representing association or composition as an attribute: Discovering Attributes Ask questions such as I am an Account, what should I know? Should I know: my account number? my account balance? my owner? my bank? For each attribute you need to decide on: name, type, accessibility (more later); Also on constant or variable, having instance or class scope (later- it will be covered under the topic Visibility Modifiers ) Usually the Many (1..M) end is held in the One (1) end 19 20

6 Attributes Account accountnumber : integer balance : float Attributes (data) Discovering methods Ask questions such as: I am an Account, what services should I provide? Should I provide services for others to: query my account number? query my account balance? change my account number? change my account balance? withdraw money? deposit money? Rule of thumb: look for verbs in the problem specs Methods data + methods = class Methods Account accountnumber : integer balance : float withdraw (amount : float) : boolean deposit (amount : float) getaccountnumber () : integer getbalance () : float Account accountnumber : integer balance : float getaccountnumber () : integer getbalance () : float withdraw (amount : float) : boolean deposit (amount : float) etc. Each class encapsulates its own data and methods owns Customer customernumber : integer name : String password : String accounts : Account [ ] getcustomernumber () : integer getname () : String getpassword () : String getaccount (index:integer) : Account getaccounts () : Account [ ] setname (aname:string) setpassword (apasswd:string) addaccount (ac:account) : boolean etc

7 Object-orientation in PHP OO in PHP PHP is NOT a purely object-oriented language: (almost) unlike Java You have a choice of writing non-oo or OO code. In the professional world PHP websites/systems, the code is most of the time Object-Oriented. In order to build larger websites/systems in PHP, it is always advisable to write code in an Object-oriented manner A class is.. Do you remember what a class is? A class is technically defined as a representation of an abstract data type. In laymen's terms a class is a blueprint from which new will construct our box. It's made up of variables and functions that allow our box to be self-aware. With the blueprint, we can build our box exactly to our specifications. Let us now write a class in PHP. OOExample1.php <?php class SimpleClass { // member declaration public $var = 'a default value'; // method declaration public function displayvar() { echo $this->var; NOTE: $this refers to an internal pointer which is used to access class members -> is known as Qualifier operator

8 Is that code enough? A class on its own is of no use. You need to create an instance of the class - object in order to use it. That can be done as: $instance = new SimpleClass(); $instance -> displayvar(); As you can see the keyword new is used to create an object of the class. -> is used to access a method from the class. OOExample2.php <?php class Dog { public $hungry = Oh yeah'; function eat($food) { $this->hungry = 'not so much'; OOExample2.php $dog = new Dog(); echo $dog->hungry; echo <br>\n ; $dog->eat('cookie'); echo $dog->hungry;?> What will the program print? Did you notice that even though hungry is a variable, we do not put $ in front of it? Output of OOExample2.php The output will be: Oh yeah.<br> not so much. $this is a reserved variable name, referring to the current instantiation of the object. By instantiating, we create a new Dog. Don t mind the public keyword for now. The initial state of this dog is that it is pretty hungry. So we feed our newly instantiated dog a treat, to modify its state. After eating cookie, doggie isn t as hungry as before

9 Constructor A Constructor is a special method that is invoked to create a new object. Its purpose is to initialise the instance variables for the new object. Constructors A Constructor usually has the same name as the class (in older versions of PHP and other languages it does). In PHP 5, it is named << construct>> It is ALWAYS invoked with the new operator. For eg, Account a = new Account(). It NEVER has a return type. By default every class is provided with a default constructor that takes no parameters (called the default constructor). For eg, public Account(). If a class provides its own constructor (that takes parameters) then the default constructor is NOT automatically provided. In this case the class MUST explicitly define the default constructor if required. Many classes have more than one constructor (with different parameter lists), ie. constructors are overloaded Constructor PHP 5 allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used. <?php class BaseClass { function construct() { print "Inside constructor\n"; Example 1- class with a constructor <?php class person { //class variables var $name; //class constructor function construct($persons_name) { $this->name = $persons_name; //functions function set_name($new_name) { $this->name = $new_name; 35 36

10 Example 1- continued function get_name() { return $this->name; //end of the class $brook = new person("brook Lynn"); echo "Brook's full name: ". $brook->get_name();?> Explanation Always remember- Functions = methods Variables = properties Constructors allow you to initialise your object's properties (translation: give your properties values,) when you instantiate (create) an object. An object is created with a constructor Now that we've created a constructor method, we can provide a value for the $name property when we create our person objects. You 'feed' the constructor method by providing a list of arguments (like you do with a function) after the class name Explanation This saves us from having to call the set_name() method reducing the amount of code. This is just an example of how the mechanisms built into OO PHP can save you time and reduce the amount of code you need to write. Less code means less bugs. Lecture 11.2 : OO- Part II 39 40

11 Access Modifier Visibility/Access Modifiers One of the fundamental principles in OOP is 'encapsulation'. The idea is that you create cleaner better code, if you restrict access to the data structures (properties) in your objects. More so, you may want to hide some of the data in the class, you may not want to provide access to your properties- instead methods may provide an indirect access to class properties. You can restrict access to class properties using something called 'access modifiers Access Modifiers In PHP, there are 3 access modifiers: public private protected Public is default access modifier. When you declare a property with the 'var' keyword, it is considered 'public'. Access modifiers When you declare a property as 'private', only the same class can access the property. When a property is declared 'protected', only the same class and classes derived from that class can access the property - this has to do with inheritance more on that later. Properties declared as 'public' have no access restrictions, meaning anyone can access them

12 Example2.php (private) <?php class person { //class variables var $name; private $pinn_number; //class constructor function construct($persons_name) { $this->name = $persons_name; //functions function set_name($new_name) { $this->name = $new_name; Example3.php <?php class phpclass{ private $var="hello"; private function format( ){ $this->var = $this->var." Shekhar"; public function getvar( ){ $this->format(); return $this->var; $obj = new phpclass( ); echo $obj->getvar( );?> 45 Example2.php $brook = new person("brook Lynn"); echo "Brook's full name: ". $brook->get_name(); echo "<br>"; echo "Tell me private stuff: ". $brook->pinn_number;?> Output: Brook's full name: Brook Lynn Fatal error: Cannot access private property person::$pinn_number in Example2.php Static keyword Declaring class members or methods as static makes them accessible without needing an instantiation of the class (i.e. you do not need to declare object to access them) A member declared as static can not be accessed with an instantiated class object (though a static method can). Because static methods are callable without an instance of the object created, the pseudo variable $this is not available inside the method declared as static. Static properties cannot be accessed through the object using the arrow operator ->

13 Static property(example4.php) <?php class Foo { public static $my_static = 'foo'; public function staticvalue() { return self::$my_static; print Foo::$my_static. "\n";?> In order to access something static, the scope-resolution (::) operator is used. Static method <?php class Foo { public static function astaticmethod() { //...?> Foo::aStaticMethod(); Inheritance Inheritance Subclasses are more specialized versions of a class, which inherit attributes and behaviours from their parent classes, and can introduce their own. For example, the class Dog might have subclasses called Collie, Chihuahua, and GoldenRetriever. Suppose the Dog class defines a method called bark() and a property called furcolor. Each of its sub-classes (Collie, Chihuahua, and GoldenRetriever) will inherit these members, meaning that the programmer only needs to write the code for them once

14 Inheritance Inheritance promotes reusability (code reuse) and extensibility. Remember the Bank example? What if the bank introduces a new product- Credit Account, which is a type of Account. Inheritance: The Credit Account example Account is-a CreditAccount accountnumber : integer balance : float creditlimit : float INTEREST : float duedate : Date outstanding : float withdraw (amount:float): boolean deposit (amount:float) calculateoutstanding ()... The Bank introduces a new product, Credit Account. A Credit Account has a credit limit, a fixed interest rate, a due date, and an outstanding amount. A Customer may withdraw up to the credit limit plus account balance. Every month, any outstanding amount after the due date will be charged to the account Inheritance in PHP (Example5.php) Often you need classes with similar variables and functions to another existing class. In fact, it is good practice to define a generic class which can be used in all your projects and adapt this class for the needs of each of your specific projects. To facilitate this, classes can be extensions of other classes. The extended or derived class has all variables and functions of the base class (this is called 'inheritance') and what you add in the extended definition. Inheritance in PHP (Example5.php) Keyword <<extends>> is used to implement Inheritance in PHP You can inherit parent/base classes constructor in a child class. Have a look at Example5.php 55 56

15 Protected keyword (Example6.php) When a property is declared 'protected', only the same class and classes derived from that class can access the property - this has to do with inheritance more on that later. Let us now look at Example6.php Class Constants Constants It is possible to define constant values on a perclass basis remaining the same and unchangeable. Constants differ from normal variables in that you don't use the $ symbol to declare or use them. The value must be a constant expression, not (for example) a variable, a class member, result of a mathematical operation or a function call. Constants in a class <?php class MyClass { const constant = 'constant value'; function showconstant() { echo self::constant. "\n"; As of PHP 5.3.0, it's possible to reference the class using a variable. The variable's value can not be a keyword (e.g. self, parent and static)

16 Constants in class (Example7.php) Let us now look at Example7.php References php information: php tutorial: Abstract Class An Abstract Class An abstract class represents a concept; classes derived from it represent implementations of the concept. In other words you can call it a template class that contains such things as variable declarations and methods, but cannot contain code for creating new instances. You cannot create an object of an abstract class As a result, you must create a sub-class to implement an abstract class

17 Abstract Class An abstract class isn't intended to be instantiated, but to serve as a parent to other classes, partly dictating how they should behave. Abstract classes can have abstract methods, these are required in the child classes. Abstract Class Example <?php abstract class Animal{ public $hungry = 'hell yeah.'; abstract public function eat($food); class Dog extends Animal{ //overriding the abstract method in the child class function eat($food){ if($food == 'cookie'){ $this->hungry = 'not so much.'; else { echo 'barf, I only like cookies!'; Abstract Class Example - cont $dog = new Dog(); echo $dog->hungry; //echoes "hell yeah." $dog->eat('peanut'); //echoes "barf, I only like cookies!?> Interface 67 68

18 Interface Interfaces are different from abstract classes. For one, they're not actually classes. They don't define properties, and they don't define any behaviour. The methods declared in an interface must be declared in classes that implement it. Interface Because an interface in the more general sense is a definition of how an object interacts with other code, all methods must be declared public. Using abstract classes, an abstract method can have any visibility, but the extending classes must have their implementations use the same (or weaker) visibility. Interfaces can be looked upon as a contract, a certificate of compliance if you will. Other code is guaranteed that a class implementing it will use certain methods to interact Interface Example <?php interface Animal { public function eat($food); interface Mammal { public function givebirth(); Interface Example class Dog implements Animal, Mammal { public $gender = 'male'; function eat($food) { if($food == 'cookie') { $this->hungry = 'not so much.'; else { echo 'barf, I only like cookies!'; 71 72

19 Interface Example function givebirth() { if($this->gender == 'male'){ echo 'I can\'t, I am a boy'; else { echo 'I\'m not even pregnant yet.';?> Overloading Overloading Object overloading in PHP refers to the mechanism where a call to a method or property will 'overload' the call to a different property or method. The call ultimately made can depend on the type of the arguments or the context. Note: If you're coming from a different OO language, the term 'overloading' likely has a very different meaning to you: defining different method with the same name having different signatures. This has nothing to do with that. Overloading These magic methods allow you catch calls to methods and properties that haven't been defined, because you didn't know (or didn't want to specify) the exact name. The magic methods are executed only if the object doesn't have the method or property declared

20 Overloading Overloading uses the following magic methods: call get set isset unset Overloading Example It is too long to be replicated here Have a look at example- Overloading.php. Note: Constructor construct() is also considered as a magic method Exception handling Remember the good-old try-catch and throw? Creating a custom exception class Try - A function using an exception should be in a "try" block. If the exception does not trigger, the code will continue as normal. However if the exception triggers, an exception is "thrown". Throw - This is how you trigger an exception. Each "throw" must have at least one "catch". Catch - A "catch" block retrieves an exception and creates an object containing the exception information 79 80

21 Creating a custom exception class Creating a custom exception handler is quite simple. We simply create a special class with functions that can be called when an exception occurs in PHP. The class must be an extension of the exception class. Example Have a look at the example- CreatingCustomException.php. The custom exception class inherits the properties from PHP's exception class and you can add custom functions to it Explanation of the example 1. The customexception() class is created as an extension of the old exception class. This way it inherits all methods and properties from the old exception class. 2. The errormessage() function is created. This function returns an error message if an address is invalid. 3. The $ variable is set to a string that is not a valid address. 4. The "try" block is executed and an exception is thrown since the address is invalid. What else is there? We have not covered the following concepts in this subject: Destructors Autoload property Final keyword Object Serialization Object Iteration and Polymorphism These are left for a more advanced subject. 5. The "catch" block catches the exception and displays the error message 83 84

22 References php information: php tutorial: 85

Object-Oriented Programming Paradigm

Object-Oriented Programming Paradigm Object-Oriented Programming Paradigm Sample Courseware Object-Oriented Programming Paradigm Object-oriented programming approach allows programmers to write computer programs by representing elements of

More information

UCLA PIC 20A Java Programming

UCLA PIC 20A Java Programming UCLA PIC 20A Java Programming Instructor: Ivo Dinov, Asst. Prof. In Statistics, Neurology and Program in Computing Teaching Assistant: Yon Seo Kim, PIC University of California, Los Angeles, Summer 2002

More information

Object oriented programming Concepts

Object oriented programming Concepts Object oriented programming Concepts Naresh Proddaturi 09/10/2012 Naresh Proddaturi 1 Problems with Procedural language Data is accessible to all functions It views a program as a series of steps to be

More information

Software Design and Analysis for Engineers

Software Design and Analysis for Engineers Software Design and Analysis for Engineers by Dr. Lesley Shannon Email: lshannon@ensc.sfu.ca Course Website: http://www.ensc.sfu.ca/~lshannon/courses/ensc251 Simon Fraser University Slide Set: 2 Date:

More information

Learn Object Oriented Programming (OOP) in PHP

Learn Object Oriented Programming (OOP) in PHP Learn Object Oriented Programming (OOP) in PHP By: Stefan Mischook - September 07 2007 www.killerphp.com - www.killersites.com - www.idea22.com Preamble: The hardest thing to learn (and teach btw,) in

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

Data Structures (list, dictionary, tuples, sets, strings)

Data 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 information

CS112 Lecture: Defining Classes. 1. To describe the process of defining an instantiable class

CS112 Lecture: Defining Classes. 1. To describe the process of defining an instantiable class CS112 Lecture: Defining Classes Last revised 2/3/06 Objectives: 1. To describe the process of defining an instantiable class Materials: 1. BlueJ SavingsAccount example project 2. Handout of code for SavingsAccount

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

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017 Overview of OOP Dr. Zhang COSC 1436 Summer, 2017 7/18/2017 Review Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in square brackets: l = [1, 2, "a"] (access by index, is mutable

More information

Chapter No. 2 Class modeling CO:-Sketch Class,object models using fundamental relationships Contents 2.1 Object and Class Concepts (12M) Objects,

Chapter No. 2 Class modeling CO:-Sketch Class,object models using fundamental relationships Contents 2.1 Object and Class Concepts (12M) Objects, Chapter No. 2 Class modeling CO:-Sketch Class,object models using fundamental relationships Contents 2.1 Object and Class Concepts (12M) Objects, Classes, Class Diagrams Values and Attributes Operations

More information

CS304 Object Oriented Programming Final Term

CS304 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 information

Argument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs.

Argument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs. Local Variable Initialization Unlike instance vars, local vars must be initialized before they can be used. Eg. void mymethod() { int foo = 42; int bar; bar = bar + 1; //compile error bar = 99; bar = bar

More information

Software Architecture (Lesson 2) Object-Oriented Paradigm (1)

Software Architecture (Lesson 2) Object-Oriented Paradigm (1) Software Architecture (Lesson 2) Object-Oriented Paradigm (1) Table of Contents Introduction... 2 1.1 Basic Concepts... 2 1.1.1 Objects... 2 1.1.2 Messages... 3 1.1.3 Encapsulation... 4 1.1.4 Classes...

More information

Basic Object-Oriented Concepts. 5-Oct-17

Basic Object-Oriented Concepts. 5-Oct-17 Basic Object-Oriented Concepts 5-Oct-17 Concept: An object has behaviors In old style programming, you had: data, which was completely passive functions, which could manipulate any data An object contains

More information

Principles of Object Oriented Programming. Lecture 4

Principles of Object Oriented Programming. Lecture 4 Principles of Object Oriented Programming Lecture 4 Object-Oriented Programming There are several concepts underlying OOP: Abstract Types (Classes) Encapsulation (or Information Hiding) Polymorphism Inheritance

More information

Object Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year

Object Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year Object Oriented Programming Assistant Lecture Omar Al Khayat 2 nd Year Syllabus Overview of C++ Program Principles of object oriented programming including classes Introduction to Object-Oriented Paradigm:Structures

More information

CS112 Lecture: Defining Instantiable Classes

CS112 Lecture: Defining Instantiable Classes CS112 Lecture: Defining Instantiable Classes Last revised 2/3/05 Objectives: 1. To describe the process of defining an instantiable class 2. To discuss public and private visibility modifiers. Materials:

More information

Object Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming

Object 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 information

Chapter 1 Getting Started

Chapter 1 Getting Started Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different

More information

Objects and Classes. Amirishetty Anjan Kumar. November 27, Computer Science and Engineering Indian Institue of Technology Bombay

Objects 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 information

COP 3330 Final Exam Review

COP 3330 Final Exam Review COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time

More information

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University Lecture 3 COMP1006/1406 (the Java course) Summer 2014 M. Jason Hinek Carleton University today s agenda assignments 1 (graded) & 2 3 (available now) & 4 (tomorrow) a quick look back primitive data types

More information

Building custom components IAT351

Building custom components IAT351 Building custom components IAT351 Week 1 Lecture 1 9.05.2012 Lyn Bartram lyn@sfu.ca Today Review assignment issues New submission method Object oriented design How to extend Java and how to scope Final

More information

C++ (Non for C Programmer) (BT307) 40 Hours

C++ (Non for C Programmer) (BT307) 40 Hours C++ (Non for C Programmer) (BT307) 40 Hours Overview C++ is undoubtedly one of the most widely used programming language for implementing object-oriented systems. The C++ language is based on the popular

More information

Inheritance (Outsource: )

Inheritance (Outsource: ) (Outsource: 9-12 9-14) is a way to form new classes using classes that have already been defined. The new classes, known as derived classes, inherit attributes and behavior of the pre-existing classes,

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

About 1. Chapter 1: Getting started with oop 2. Remarks 2. Examples 2. Introduction 2. OOP Introduction 2. Intoduction 2. OOP Terminology 3.

About 1. Chapter 1: Getting started with oop 2. Remarks 2. Examples 2. Introduction 2. OOP Introduction 2. Intoduction 2. OOP Terminology 3. oop #oop Table of Contents About 1 Chapter 1: Getting started with oop 2 Remarks 2 Examples 2 Introduction 2 OOP Introduction 2 Intoduction 2 OOP Terminology 3 Java 3 C++ 3 Python 3 Java 4 C++ 4 Python

More information

MITOCW watch?v=flgjisf3l78

MITOCW watch?v=flgjisf3l78 MITOCW watch?v=flgjisf3l78 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high-quality educational resources for free. To

More information

Super-Classes and sub-classes

Super-Classes and sub-classes Super-Classes and sub-classes Subclasses. Overriding Methods Subclass Constructors Inheritance Hierarchies Polymorphism Casting 1 Subclasses: Often you want to write a class that is a special case of an

More information

Chapter 12. OOP: Creating Object-Oriented Programs The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill

Chapter 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 information

CS 162, Lecture 25: Exam II Review. 30 May 2018

CS 162, Lecture 25: Exam II Review. 30 May 2018 CS 162, Lecture 25: Exam II Review 30 May 2018 True or False Pointers to a base class may be assigned the address of a derived class object. In C++ polymorphism is very difficult to achieve unless you

More information

JAVA GUI PROGRAMMING REVISION TOUR III

JAVA GUI PROGRAMMING REVISION TOUR III 1. In java, methods reside in. (a) Function (b) Library (c) Classes (d) Object JAVA GUI PROGRAMMING REVISION TOUR III 2. The number and type of arguments of a method are known as. (a) Parameter list (b)

More information

CS304- Object Oriented Programming LATEST SOLVED MCQS FROM FINALTERM PAPERS. MC

CS304- Object Oriented Programming LATEST SOLVED MCQS FROM FINALTERM PAPERS. MC CS304- Object Oriented Programming LATEST SOLVED MCQS FROM FINALTERM PAPERS JAN 28,2011 MC100401285 Moaaz.pk@gmail.com Mc100401285@gmail.com PSMD01 FINALTERM EXAMINATION 14 Feb, 2011 CS304- Object Oriented

More information

Object-Oriented Programming (OOP) Fundamental Principles of OOP

Object-Oriented Programming (OOP) Fundamental Principles of OOP Object-Oriented Programming (OOP) O b j e c t O r i e n t e d P r o g r a m m i n g 1 Object-oriented programming is the successor of procedural programming. The problem with procedural programming is

More information

Introduction to Inheritance

Introduction 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 information

Classes, objects, methods and properties

Classes, objects, methods and properties Learning Object 1. African Virtual University Template for extracting a learning object Main Learning Objective Nature of learning object Key concept (s) Source Module information Access source module

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

Cpt S 122 Data Structures. Course Review Midterm Exam # 2

Cpt S 122 Data Structures. Course Review Midterm Exam # 2 Cpt S 122 Data Structures Course Review Midterm Exam # 2 Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Midterm Exam 2 When: Monday (11/05) 12:10 pm -1pm

More information

Lesson Plan. Subject: OBJECT ORIENTED PROGRAMMING USING C++ :15 weeks (From January, 2018 to April,2018)

Lesson Plan. Subject: OBJECT ORIENTED PROGRAMMING USING C++ :15 weeks (From January, 2018 to April,2018) Lesson Plan Name of the Faculty Discipline Semester :Mrs. Reena Rani : Computer Engineering : IV Subject: OBJECT ORIENTED PROGRAMMING USING C++ Lesson Plan Duration :15 weeks (From January, 2018 to April,2018)

More information

Overview. OOP: model, map, reuse, extend. Examples of objects. Introduction to Object Oriented Design

Overview. OOP: model, map, reuse, extend. Examples of objects. Introduction to Object Oriented Design Overview Introduction to Object Oriented Design Understand Classes and Objects. Understand some of the key concepts/features in the Object Oriented paradigm. Benefits of Object Oriented Design paradigm.

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

CPS 506 Comparative Programming Languages. Programming Language

CPS 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 information

And Even More and More C++ Fundamentals of Computer Science

And 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 information

Subclasses, Superclasses, and Inheritance

Subclasses, Superclasses, and Inheritance Subclasses, Superclasses, and Inheritance To recap what you've seen before, classes can be derived from other classes. The derived class (the class that is derived from another class) is called a subclass.

More information

Object-oriented. Service Innovation

Object-oriented. Service Innovation Object-oriented Service Innovation Overall Concepts Real World OO World Collaboration Delegation using services at SAP (service access point) 사과 3 개 Abstract Interacting, Collaborating Objects by Delegating

More information

CREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed

CREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed CREATED BY: Muhammad Bilal Arslan Ahmad Shaad JAVA Chapter No 5 Instructor: Muhammad Naveed Muhammad Bilal Arslan Ahmad Shaad Chapter No 5 Object Oriented Programming Q: Explain subclass and inheritance?

More information

CS304 Object Oriented Programming

CS304 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 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

Lecture 06: Classes and Objects

Lecture 06: Classes and Objects Accelerating Information Technology Innovation http://aiti.mit.edu Lecture 06: Classes and Objects AITI Nigeria Summer 2012 University of Lagos. What do we know so far? Primitives: int, float, double,

More information

Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING

Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING THROUGH C++ Practical: OOPS THROUGH C++ Subject Code: 1618407 PROGRAM NO.1 Programming exercise on executing a Basic C++

More information

CPS122 Lecture: Defining a Class

CPS122 Lecture: Defining a Class Objectives: CPS122 Lecture: Defining a Class last revised January 14, 2016 1. To introduce structure of a Java class 2. To introduce the different kinds of Java variables (instance, class, parameter, local)

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

Day 4. COMP1006/1406 Summer M. Jason Hinek Carleton University

Day 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 information

Chapter 11. Categories of languages that support OOP: 1. OOP support is added to an existing language

Chapter 11. Categories of languages that support OOP: 1. OOP support is added to an existing language Categories of languages that support OOP: 1. OOP support is added to an existing language - C++ (also supports procedural and dataoriented programming) - Ada 95 (also supports procedural and dataoriented

More information

Object-Oriented Programming Concepts

Object-Oriented Programming Concepts Object-Oriented Programming Concepts Real world objects include things like your car, TV etc. These objects share two characteristics: they all have state and they all have behavior. Software objects are

More information

Day 3. COMP 1006/1406A Summer M. Jason Hinek Carleton University

Day 3. COMP 1006/1406A Summer M. Jason Hinek Carleton University Day 3 COMP 1006/1406A Summer 2016 M. Jason Hinek Carleton University today s agenda assignments 1 was due before class 2 is posted (be sure to read early!) a quick look back testing test cases for arrays

More information

The 10 Minute Guide to Object Oriented Programming

The 10 Minute Guide to Object Oriented Programming The 10 Minute Guide to Object Oriented Programming Why read this? Because the main concepts of object oriented programming (or OOP), often crop up in interviews, and all programmers should be able to rattle

More information

Java Programming Lecture 7

Java Programming Lecture 7 Java Programming Lecture 7 Alice E. Fischer Feb 16, 2015 Java Programming - L7... 1/16 Class Derivation Interfaces Examples Java Programming - L7... 2/16 Purpose of Derivation Class derivation is used

More information

Java OOP (SE Tutorials: Learning the Java Language Trail : Object-Oriented Programming Concepts Lesson )

Java OOP (SE Tutorials: Learning the Java Language Trail : Object-Oriented Programming Concepts Lesson ) Java OOP (SE Tutorials: Learning the Java Language Trail : Object-Oriented Programming Concepts Lesson ) Dongwon Jeong djeong@kunsan.ac.kr; http://ist.kunsan.ac.kr/ Information Sciences and Technology

More information

Object- Oriented Design with UML and Java Part I: Fundamentals

Object- Oriented Design with UML and Java Part I: Fundamentals Object- Oriented Design with UML and Java Part I: Fundamentals University of Colorado 1999-2002 CSCI-4448 - Object-Oriented Programming and Design These notes as free PDF files: http://www.softwarefederation.com/cs4448.html

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

The Essence of Object Oriented Programming with Java and UML. Chapter 2. The Essence of Objects. What Is an Object-Oriented System?

The Essence of Object Oriented Programming with Java and UML. Chapter 2. The Essence of Objects. What Is an Object-Oriented System? Page 1 of 21 Page 2 of 21 and identity. Objects are members of a class, and the attributes and behavior of an object are defined by the class definition. The Essence of Object Oriented Programming with

More information

Pieter van den Hombergh Thijs Dorssers Stefan Sobek. January 11, 2018

Pieter van den Hombergh Thijs Dorssers Stefan Sobek. January 11, 2018 Inheritance and Inheritance and Pieter van den Hombergh Thijs Dorssers Stefan Sobek Java Inheritance Example I Visibility peekabo Constructors Fontys Hogeschool voor Techniek en Logistiek January 11, 2018

More information

ECE 3574: Dynamic Polymorphism using Inheritance

ECE 3574: Dynamic Polymorphism using Inheritance 1 ECE 3574: Dynamic Polymorphism using Inheritance Changwoo Min 2 Administrivia Survey on class will be out tonight or tomorrow night Please, let me share your idea to improve the class! 3 Meeting 10:

More information

JAVA: A Primer. By: Amrita Rajagopal

JAVA: A Primer. By: Amrita Rajagopal JAVA: A Primer By: Amrita Rajagopal 1 Some facts about JAVA JAVA is an Object Oriented Programming language (OOP) Everything in Java is an object application-- a Java program that executes independently

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

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

Computer Science II. OO Programming Classes Scott C Johnson Rochester Institute of Technology

Computer Science II. OO Programming Classes Scott C Johnson Rochester Institute of Technology Computer Science II OO Programming Classes Scott C Johnson Rochester Institute of Technology Outline Object-Oriented (OO) Programming Review Initial Implementation Constructors Other Standard Behaviors

More information

Why use inheritance? The most important slide of the lecture. Programming in C++ Reasons for Inheritance (revision) Inheritance in C++

Why use inheritance? The most important slide of the lecture. Programming in C++ Reasons for Inheritance (revision) Inheritance in C++ Session 6 - Inheritance in C++ The most important slide of the lecture Dr Christos Kloukinas City, UoL http://staff.city.ac.uk/c.kloukinas/cpp (slides originally produced by Dr Ross Paterson) Why use inheritance?

More information

Introduction to Computers and Programming Languages. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

Introduction to Computers and Programming Languages. CS 180 Sunil Prabhakar Department of Computer Science Purdue University Introduction to Computers and Programming Languages CS 180 Sunil Prabhakar Department of Computer Science Purdue University 1 Objectives This week we will study: The notion of hardware and software Programming

More information

CS 251 Intermediate Programming Methods and Classes

CS 251 Intermediate Programming Methods and Classes CS 251 Intermediate Programming Methods and Classes Brooke Chenoweth University of New Mexico Fall 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

CS 251 Intermediate Programming Methods and More

CS 251 Intermediate Programming Methods and More CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 05: Inheritance and Interfaces MOUNA KACEM mouna@cs.wisc.edu Spring 2018 Inheritance and Interfaces 2 Introduction Inheritance and Class Hierarchy Polymorphism Abstract

More information

Inheritance, and Polymorphism.

Inheritance, and Polymorphism. Inheritance and Polymorphism by Yukong Zhang Object-oriented programming languages are the most widely used modern programming languages. They model programming based on objects which are very close to

More information

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.

OOPS 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 information

Inheritance (IS A Relationship)

Inheritance (IS A Relationship) Inheritance (IS A Relationship) We've talked about the basic idea of inheritance before, but we haven't yet seen how to implement it. Inheritance encapsulates the IS A Relationship. A String IS A Object.

More information

CMSC 132: Object-Oriented Programming II

CMSC 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 information

Relationships Between Real Things. CSE 143 Java. Common Relationship Patterns. Composition: "has a" CSE143 Sp Student.

Relationships Between Real Things. CSE 143 Java. Common Relationship Patterns. Composition: has a CSE143 Sp Student. CSE 143 Java 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

More information

Lecture Notes on Programming Languages

Lecture Notes on Programming Languages Lecture Notes on Programming Languages 85 Lecture 09: Support for Object-Oriented Programming This lecture discusses how programming languages support object-oriented programming. Topics to be covered

More information

STUDENT LESSON A5 Designing and Using Classes

STUDENT LESSON A5 Designing and Using Classes STUDENT LESSON A5 Designing and Using Classes 1 STUDENT LESSON A5 Designing and Using Classes INTRODUCTION: This lesson discusses how to design your own classes. This can be the most challenging part of

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

Software Engineering /48

Software Engineering /48 Software Engineering 1 /48 Topics 1. The Compilation Process and You 2. Polymorphism and Composition 3. Small Functions 4. Comments 2 /48 The Compilation Process and You 3 / 48 1. Intro - How do you turn

More information

Chapter 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. 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 information

CSE : Python Programming

CSE : Python Programming CSE 399-004: Python Programming Lecture 2: Data, Classes, and Modules January 22, 2007 http://www.seas.upenn.edu/~cse39904/ Administrative things Teaching assistant Brian Summa (bsumma @ seas.upenn.edu)

More information

Introduction to Programming Using Java (98-388)

Introduction 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 information

CMSC131. Inheritance. Object. When we talked about Object, I mentioned that all Java classes are "built" on top of that.

CMSC131. Inheritance. Object. When we talked about Object, I mentioned that all Java classes are built on top of that. CMSC131 Inheritance Object When we talked about Object, I mentioned that all Java classes are "built" on top of that. This came up when talking about the Java standard equals operator: boolean equals(object

More information

Programming II (CS300)

Programming 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 information

Object-Oriented Programming

Object-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 information

EXAM Microsoft MTA Software Development Fundamentals. Buy Full Product.

EXAM Microsoft MTA Software Development Fundamentals. Buy Full Product. Microsoft EXAM - 98-361 Microsoft MTA Software Development Fundamentals Buy Full Product http://www.examskey.com/98-361.html Examskey Microsoft 98-361 exam demo product is here for you to test the quality

More information

Object Oriented Features. Inheritance. Inheritance. CS257 Computer Science I Kevin Sahr, PhD. Lecture 10: Inheritance

Object Oriented Features. Inheritance. Inheritance. CS257 Computer Science I Kevin Sahr, PhD. Lecture 10: Inheritance CS257 Computer Science I Kevin Sahr, PhD Lecture 10: Inheritance 1 Object Oriented Features For a programming language to be called object oriented it should support the following features: 1. objects:

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

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

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism Block 1: Introduction to Java Unit 4: Inheritance, Composition and Polymorphism Aims of the unit: Study and use the Java mechanisms that support reuse, in particular, inheritance and composition; Analyze

More information

1: Introduction to Object (1)

1: Introduction to Object (1) 1: Introduction to Object (1) 김동원 2003.01.20 Overview (1) The progress of abstraction Smalltalk Class & Object Interface The hidden implementation Reusing the implementation Inheritance: Reusing the interface

More information

OVERRIDING. 7/11/2015 Budditha Hettige 82

OVERRIDING. 7/11/2015 Budditha Hettige 82 OVERRIDING 7/11/2015 (budditha@yahoo.com) 82 What is Overriding Is a language feature Allows a subclass or child class to provide a specific implementation of a method that is already provided by one of

More information

Inheritance and Polymorphism

Inheritance and Polymorphism Division of Mathematics and Computer Science Maryville College Outline Inheritance 1 Inheritance 2 3 Outline Inheritance 1 Inheritance 2 3 The "is-a" Relationship The "is-a" Relationship Object classification

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

Review sheet for Final Exam (List of objectives for this course)

Review sheet for Final Exam (List of objectives for this course) Review sheet for Final Exam (List of objectives for this course) Please be sure to see other review sheets for this semester Please be sure to review tests from this semester Week 1 Introduction Chapter

More information

Supporting Class / C++ Lecture Notes

Supporting Class / C++ Lecture Notes Goal Supporting Class / C++ Lecture Notes You started with an understanding of how to write Java programs. This course is about explaining the path from Java to executing programs. We proceeded in a mostly

More information