CS 10: Problem solving via Object Oriented Programming. Lists Part 1

Size: px
Start display at page:

Download "CS 10: Problem solving via Object Oriented Programming. Lists Part 1"

Transcription

1 CS 10: Problem solving via Object Oriented Programming Lists Part 1

2 Agenda 1. Defining a List ADT 2. Generics 3. Singly linked list implementaeon 4. ExcepEons 5. Visibility: public vs. private vs. protected vs. package 2

3 Abstract Data Types specify operaeons on a data set that defines overall behavior Abstract Data Types (ADTs) ADTs specify a set of opera&ons (e.g., get, set, add, ) that define how the ADT behaves on a colleceon of data elements At the ADT level we don t know (and don t really care) how data elements are stored (e.g., linked list or array or something else, it doesn t mater) Also do not care about what kind of data the ADT holds (e.g., Strings, integers, Objects). This is the Abstract in Abstract Data Type Big idea: hide the way data is represented while allowing others to work with the data in a consistent manner 3

4 Example: List ADT defines a set of operaeons List holds mul8ple elements (items) referenced by posi8on in List Index Bob Elvis Alice Denise Charlie 4

5 Example: List ADT defines a set of operaeons List holds mul8ple elements (items) referenced by posi8on in List Index Bob Elvis Alice Denise Charlie get(3) returns Denise 5

6 Example: List ADT defines a set of operaeons List holds mul8ple elements (items) referenced by posi8on in List set(2,abby) replaces Alice with Abby Index Bob Elvis Abby Alice Denise Charlie get(3) returns Denise 6

7 Example: List ADT defines a set of operaeons List holds mul8ple elements (items) referenced by posi8on in List set(2,abby) replaces Alice with Abby add(5,falcon) adds to end of List Index Bob Elvis Abby Denise Charlie Falcon get(3) returns Denise 7

8 Example: List ADT defines a set of operaeons List holds mul8ple elements (items) referenced by posi8on in List set(2,abby) replaces Alice with Abby add(5,falcon) adds to end of List Index Bob Elvis Abby Denise Charlie Falcon get(3) returns Denise ADT defines these opera8ons (and others) How were these items stored? Array? Linked List? We don t know and don t care at the ADT level, we just care that the operaeons (get, set, add, ) work as expected What type of elements are these? Strings, Student Objects? See answer above The type of element doesn t affect how the ADT works! 8

9 ADT can be implemented in different ways, but must provide common funceonality Java Interface: Defines set of ADT operaeons (e.g., get, set, add, remove, ) Interface does not say how to implement, just what to implement List ADT Implementa8on: Code to implement operaeons defined by interface Can be writen using different data structures MUST implement all funceonality defined by interface Can include other funceonality ArrayList Elements stored in an Array LinkedList Elements stored in an Linked List Java has both ArrayList and LinkedList implementaeons of List Both implementaeons provide the same funceonality as 9 required by interface, but store data differently

10 The List Interface describes several operaeons, but not implementaeons List ADT Opera8on size() isempty() get(i) set(i,e) add(i,e) remove(i) Descrip8on Return number of items in List True if no items in List, otherwise false Return the item at index i Replace the item at index i with item e Insert item e at index i, moving all subsequent items one index larger Remove and return item at index i, move all subsequent items one index smaller These operaeons MUST be implemented to complete the ADT Free to implement other methods, but must have these NoEce the familiar look from Java s ArrayList 10

11 Interfaces go in one file, implementaeons go in another file Interface file Specifies required operaeons SimpleList.java Uses keyword interface Linked list implementa8on SinglyLinked.java OR Array implementa8on Implementa8on file Actually implements required operaeons using a specific data structure Same interface could be implemented in different ways (e.g., linked list or array) Use keyword implements to implement an interface 11

12 SimpleList.java is an interface that specifies what operaeons MUST be implemented Interface keyword tells Java this is an interface Methods defined to include parameters and return types (called a signature ) If you are going to create a List, then you MUST implement these methods How you implement is your business 12

13 The List ADT could be implemented with a singly linked list OR an array; either works Examples of List implementa8on Singly linked list We will implement a List both ways Each implementa8on has pros and cons head Alice Bob Charlie Array 0 1 Alice Bob Charlie 2 n- 1 13

14 Agenda 1. Defining a List ADT 2. Generics 3. Singly linked list implementaeon 4. ExcepEons 5. Visibility: public vs. private vs. protected vs. package 14

15 Generics allow a variable to stand in for a Java type Interface declara8on public interface SimpleList<T> {... public T get(int index) throws Exception; public void add(int index, T item) throws Exception; } T stands for whatever object type we instaneate SimpleList<Blob> then T always stands for Blob SimpleList<Point> then T always stands for Point Allows us to write one implementaeon that works regardless of what kind of Object we store in our data set Must use class version of primieves (Integer, Double, etc) By conveneon we name type of variables with a single uppercase leter, oken T for type, later we ll use K for key and V for value 15

16 Agenda 1. Defining a List ADT 2. Generics 3. Singly linked list implementaeon 4. ExcepEons 5. Visibility: public vs. private vs. protected vs. package 16

17 Singly linked list review: elements have data and a next pointer Singly linked list Box- and- pointer diagram Data in Box Pointer to next item in List head head points to first item (index 0) null if list is empty Alice Bob Charlie Slash indicates end of List next pointer is null 17

18 To get an item at index i, start at head and march down get(i) return item at specified index head Alice Bob Charlie Get item at index 2 18

19 To get an item at index i, start at head and march down get(i) return item at specified index Index 0 head Alice Bob Charlie Get item at index 2 1. Start at head (index 0) 19

20 To get an item at index i, start at head and march down get(i) return item at specified index Index 1 head Alice Bob Charlie Get item at index 2 1. Start at head (index 0) 2. Follow next pointer to index 1 20

21 To get an item at index i, start at head and march down get(i) return item at specified index Index 2 head Alice Bob Charlie Get item at index 2 1. Start at head (index 0) 2. Follow next pointer to index 1 3. Follow next pointer to index 2 21

22 To get an item at index i, start at head and march down get(i) return item at specified index Item 2 head Alice Bob Charlie Get item at index 2 1. Start at head (index 0) 2. Follow next pointer to index 1 3. Follow next pointer to index 2 4. Return Charlie (index 2) 22

23 add() splices in a new object anywhere in the list by updaeng next pointers add(1, Bill ) head Alice Bob Charlie Add Bill at index idx=1 Advance from head to idx- 1 (Alice) Bill 23

24 add() splices in a new object anywhere in the list by updaeng next pointers add(1, Bill ) Index 0 (=idx- 1) head Alice Bob Charlie Add Bill at index idx=1 Advance from head to idx- 1 (Alice) Bill 24

25 add() splices in a new object anywhere in the list by updaeng next pointers add(1, Bill ) head Alice Bob Charlie Add Bill at index idx=1 Advance from head to idx- 1 (Alice) Update Bill s next pointer to same address as Alice s next pointer Bill 25

26 add() splices in a new object anywhere in the list by updaeng next pointers add(1, Bill ) head Alice Bob Charlie Bill Add Bill at index idx=1 Advance from head to idx- 1 (Alice) Update Bill s next pointer to same address as Alice s next pointer Update Alice s next pointer to Bill 26

27 add() splices in a new object anywhere in the list by updaeng next pointers add(1, Bill ) head Alice Bob Charlie Bill Add Bill at index idx=1 Advance from head to idx- 1 (Alice) Update Bill s next pointer to same address as Alice s next pointer Update Alice s next pointer to Bill 27

28 remove() takes an item out of the list by updaeng next pointer remove(1) head Alice Bob Charlie Remove Bill at index idx=1 Advance from head to idx- 1 (Alice) Bill 28

29 remove() takes an item out of the list by updaeng next pointer remove(1) head Alice Bob Charlie Bill Remove Bill at index idx=1 Advance from head to idx- 1 (Alice) Set Alice s next pointer to Bill s next pointer (the next element s next) 29

30 remove() takes an item out of the list by updaeng next pointer remove(1) head Alice Bob Charlie Bill Remove Bill at index idx=1 Advance from head to idx- 1 (Alice) Set Alice s next pointer to Bill s next pointer (the next element s next) Bill will be garbage collected (in C we have to call free()) 30

31 SinglyLinked.java: ImplementaEon of List interface implements is a promise to implement all required methods specified by Interface SimpleList isempty() size() add() remove() get() set() 31

32 SinglyLinked.java: ImplementaEon of List interface Type of data is generic T Don t care what kind of data the List holds, could be Strings, Integers, Blob Objects, This way we don t have to write a separate implementa8on if use Strings as elements, and other implementa8on if use Integers, and third implementa8on if use Just implement the List once and hold whatever data type needed for the applica8on 32

33 SinglyLinked.java: ImplementaEon of List interface Define a private class called Element to implement data and next pointers Element constructor takes data as type T and pointer to next Element (could be null) Element is private to SinglyLinked (internal to this file, no need for others to change it) 33

34 SinglyLinked.java: ImplementaEon of List interface Creates head Element and size counter Constructor ini8alizes head to null and size to 0 No8ce head is of type Element but is never newed head will be a pointer to first Element in the List 34

35 SinglyLinked.java: ImplementaEon of List interface size() method just returns instance variable size size will be incremented on add(), decremented on remove() 35

36 SinglyLinked.java: ImplementaEon of List interface advance() helper method Start at head and marches down n items Loop un8l hit n th item or run out of items in List Return n th item (or throw excep8on) Note: return type from advance() is Element advance() not specified by interface, but implementa8ons can have more methods than required 36

37 SinglyLinked.java: ImplementaEon of List interface add()/remove() use advance() to march down list to item before index idx, then adjust pointers 37

38 SinglyLinked.java: ImplementaEon of List interface Safety check for nega8ve index head 38

39 SinglyLinked.java: ImplementaEon of List interface If adding at head (index 0) add(0,15) head 39

40 SinglyLinked.java: ImplementaEon of List interface If adding at head (index 0) Create new element with data set to parameter item add(0,15) head 15 40

41 SinglyLinked.java: ImplementaEon of List interface If adding at head (index 0) Create new element with data set to parameter item Set new element next pointer to where ever head points add(0,15) head 15 41

42 SinglyLinked.java: ImplementaEon of List interface If adding at head (index 0) Create new element with data set to parameter item Set new element next pointer to where ever head points head will ini8ally point to null add(0,15) head 15 42

43 SinglyLinked.java: ImplementaEon of List interface If adding at head (index 0) Create new element with data set to parameter item Set new element next pointer to where ever head points head will ini8ally point to null Set head to new element add(0,15) head 15 43

44 SinglyLinked.java: ImplementaEon of List interface add(0,15) If adding at head (index 0) Create new element with data set to parameter item Set new element next pointer to where ever head points head will ini8ally point to null Set head to new element Finally increment size head 15 44

45 SinglyLinked.java: ImplementaEon of List interface add(0,6) head 15 45

46 SinglyLinked.java: ImplementaEon of List interface If adding at head (index 0) Create new element with data set to parameter item Set new element next pointer to where ever head points add(0,6) head

47 SinglyLinked.java: ImplementaEon of List interface If adding at head (index 0) Create new element with data set to parameter item Set new element next pointer to where ever head points Set head to new element Finally increment size add(0,6) head

48 SinglyLinked.java: ImplementaEon of List interface If adding not at head advance() to e=(idx- 1) th item add(1,3) head

49 SinglyLinked.java: ImplementaEon of List interface If adding not at head advance() to e=(idx- 1) th item add(1,3) head 6 15 Advance to item idx- 1 Here (item 1)- 1 = item 0 So e points to item 0 with data = 6 49

50 SinglyLinked.java: ImplementaEon of List interface If adding not at head advance() to e=(idx- 1) th item Create new Element with data set to item and next to e.next add(1,3) head

51 SinglyLinked.java: ImplementaEon of List interface add(1,3) If adding not at head advance() to e=(idx- 1) th item Create new Element with data set to item and next to e.next Set e.next = new item head

52 SinglyLinked.java: ImplementaEon of List interface add(1,3) If adding not at head advance() to e=(idx- 1) th item Create new Element with data set to item and next to e.next Set e.next = new item Finally, increment size head

53 SinglyLinked.java: ImplementaEon of List interface If removing at head Just set head to next remove(0) head

54 SinglyLinked.java: ImplementaEon of List interface If removing at head Just set head to next remove(0) head

55 SinglyLinked.java: ImplementaEon of List interface If removing at head Just set head to next remove(0) head

56 SinglyLinked.java: ImplementaEon of List interface If removing not at head advance() to idx- 1 (data 3) Set e.next to e.next.next remove(1) head

57 SinglyLinked.java: ImplementaEon of List interface If removing not at head advance() to idx- 1 (data 3) Set e.next to e.next.next remove(1) head

58 SinglyLinked.java: ImplementaEon of List interface If removing not at head advance() to idx- 1 (data 3) Set e.next to e.next.next remove(1) head 3 58

59 SinglyLinked.java: ImplementaEon of List interface get()/set() also use advance() to march down list, this 8me to index idx 59

60 SinglyLinked.java: ImplementaEon of List interface get()/set() also use advance() to march down list, this 8me to index idx tostring() overrides a Java Object method and allows us to print an object as desired If tostring() not overriden, defaults to prin8ng the memory address of object Return value type is String rather than actually prin8ng 60

61 ListTest.java: Test of List implementaeon Declare SinglyLinked List to hold Strings, so T = String in the implementa8on Implementa8on is SinglyLinked which implemented SimpleList interface Next class we ll look at an array implementa8on which will also be a SimpleList 61

62 ListTest.java: Test of List implementaeon tostring() method called in print statements 62

63 ListTest.java: Test of List implementaeon tostring() method called in print statements Remember, tostring() returns a String (doesn t do the prin8ng) 63

64 Agenda 1. Defining a List ADT 2. Generics 3. Singly linked list implementaeon 4. ExcepEons 5. Visibility: public vs. private vs. protected vs. package 64

65 An excepeon indicates that something unexpected happened at run- Eme Cannot check for all errors at compile Eme What if we ask for element at an index of - 1 in an array? There is no clear, always- do- this, answer Maybe we should return null or maybe we should stop execueon ExcepEons provide a way to show something is amiss, and let calling funceons deal with error (or not) ExcepEons not handled by a method are passed to calling method. If excepeon not handled in main() or before, program stops Throw error with throw new Exception( error description ) Java provides structured error- handling via try/catch/finally blocks catch executes only if there is an excepeon in try body catch block can specify the type of error it handles Can have muleple catch blocks for each try 65 Finally block executes regardless whether try succeeds or fails

66 ListExcepEons.java: ExcepEons can be handled with try/catch/finally blocks Create new SinglyLinked List 66

67 ListExcepEons.java: ExcepEons can be handled with try/catch/finally blocks Try block Catch block Only executes if excep8on in try block 67

68 ListExcepEons.java: ExcepEons can be handled with try/catch/finally blocks Trying to add at index - 1 is an error, the catch block will execute because add() throws an excep8on for nega8ve indices 68

69 ListExcepEons.java: ExcepEons can be handled with try/catch/finally blocks Trying to add at index - 1 is an error, the catch block will execute because add() throws an excep8on for nega8ve indices SinglyLinked.java 69

70 ListExcepEons.java: ExcepEons can be handled with try/catch/finally blocks Trying to add at index - 1 is an error, the catch block will execute because add() throws an excep8on for nega8ve indices Catch block on line 15 executes because excep8on thrown on line 10 Lines 11 and 12 never execute because excep8on on line 10 stops execu8on in try block and starts running in catch block I never run and Neither do I are not printed If we didn t catch excep8on, the program would end because main() wouldn t have caught the excep8on (but we did catch 70 it, so main() doesn t end execu8on)

71 ListExcepEons.java: ExcepEons can be handled with try/catch/finally blocks Trying to add at index - 1 is s&ll an error, the catch block will execute 71

72 ListExcepEons.java: ExcepEons can be handled with try/catch/finally blocks Trying to add at index - 1 is s&ll an error, the catch block will execute We can see what the excep8on was by prin8ng e (it is just an object) 72

73 ListExcepEons.java: ExcepEons can be handled with try/catch/finally blocks finally always executes, regardless of whether excep8on in try block catch only executes if excep8on occurs in try block, otherwise catch code does not execute If excep8on in try block, execu8on in the try block stops at the point of the excep8on and picks up in first line of catch block Code in the try block afer the line that caused the excep8on is not executed 73

74 ListExcepEons.java: ExcepEons can be handled with try/catch/finally blocks This is valid, so catch block does not execute 74

75 ListExcepEons.java: ExcepEons can be handled with try/catch/finally blocks This is valid, so catch block does not execute finally always executes, even if no excep8on in try block 75

76 Agenda 1. Defining a List ADT 2. Generics 3. Singly linked list implementaeon 4. ExcepEons 5. Visibility: public vs. private vs. protected vs. package 76

77 Java allows us to break up major poreons of code into Projects, Packages and Classes Example of master project for a company Main Project Company Project 77

78 Java allows us to break up major poreons of code into Projects, Packages and Classes Example of master project for a company Main Project Company Project Packages within Project AccounEng Package MarkeEng Package Manufacturing Package 78

79 Java allows us to break up major poreons of code into Projects, Packages and Classes Example of master project for a company Main Project Company Project Packages within Project AccounEng Package MarkeEng Package Manufacturing Package Classes within Package AccounEng Class 1 Manufacturing Class 1 MarkeEng Class 1 AccounEng Class n Manufacturing Class n MarkeEng Class n 79

80 Adapted from Java documentaeon Visibility depends on modifier applied Example: Visibility of Alpha class Company Project Alpha is a class in Accoun&ng package, which is in Company project Packages (Pkg) Classes AccounEng Package Alpha Beta Subclass MarkeEng Package AlphaSub Gamma Y = can access N = cannot access Alpha.x Accoun8ng Pkg Marke8ng Pkg If Alpha.x is: accessed by: Alpha Beta AlphaSub Gamma public Any class Y Y Y Y protected Pkg + Subclass Y Y Y N No modifier Pkg - Subclass Y Y N N private This class only Y N N N 80

81 Adapted from Java documentaeon Visibility depends on modifier applied Example: Visibility of Alpha class Company Project Alpha is a class in Accoun&ng package, which is in Company project Packages (Pkg) Classes AccounEng Package Alpha Beta Subclass MarkeEng Package AlphaSub Gamma Y = can access N = cannot access Alpha.x Accoun8ng Pkg Marke8ng Pkg If Alpha.x is: accessed by: Alpha Beta AlphaSub Gamma public Any class Y Y Y Y protected Pkg + Subclass Y Y Y N No modifier Pkg - Subclass Y Y N N private This class only Y N N N 81

82 Adapted from Java documentaeon Visibility depends on modifier applied Example: Visibility of Alpha class Company Project Alpha is a class in Accoun&ng package, which is in Company project Packages (Pkg) Classes AccounEng Package Alpha Beta Subclass MarkeEng Package AlphaSub Gamma Y = can access N = cannot access Alpha.x Accoun8ng Pkg Marke8ng Pkg If Alpha.x is: accessed by: Alpha Beta AlphaSub Gamma public Any class Y Y Y Y protected Pkg + Subclass Y Y Y N No modifier Pkg - Subclass Y Y N N private This class only Y N N N 82

83 Adapted from Java documentaeon Visibility depends on modifier applied Example: Visibility of Alpha class Company Project Alpha is a class in Accoun&ng package, which is in Company project Packages (Pkg) Classes AccounEng Package Alpha Beta Subclass MarkeEng Package AlphaSub Gamma Y = can access N = cannot access Alpha.x Accoun8ng Pkg Marke8ng Pkg If Alpha.x is: accessed by: Alpha Beta AlphaSub Gamma public Any class Y Y Y Y protected Pkg + Subclass Y Y Y N No modifier Pkg - Subclass Y Y N N private This class only Y N N N 83

84 Adapted from Java documentaeon Visibility depends on modifier applied Example: Visibility of Alpha class Company Project Alpha is a class in Accoun&ng package, which is in Company project Packages (Pkg) Classes AccounEng Package Alpha Beta Subclass MarkeEng Package AlphaSub Gamma Y = can access N = cannot access Alpha.x Accoun8ng Pkg Marke8ng Pkg If Alpha.x is: accessed by: Alpha Beta AlphaSub Gamma public Any class Y Y Y Y protected Pkg + Subclass Y Y Y N No modifier Pkg - Subclass Y Y N N private This class only Y N N N 84

85 85

CS 10: Problem solving via Object Oriented Programming. Info Retrieval

CS 10: Problem solving via Object Oriented Programming. Info Retrieval CS 10: Problem solving via Object Oriented Programming Info Retrieval ADT Overview Descrip+on List Keep items stored in order Common use Grow to hold any number of items Implementa+on op+ons Java provided

More information

Array Based Lists. Collections

Array Based Lists. Collections Array Based Lists Reading: RS Chapter 15 1 Collections Data structures stores elements in a manner that makes it easy for a client to work with the elements Specific collections are specialized for particular

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 07: Linked Lists MOUNA KACEM mouna@cs.wisc.edu Spring 2019 Linked Lists 2 Introduction Linked List Abstract Data Type SinglyLinkedList ArrayList Keep in Mind Introduction:

More information

+ Abstract Data Types

+ Abstract Data Types Linked Lists Abstract Data Types An Abstract Data Type (ADT) is: a set of values a set of operations Sounds familiar, right? I gave a similar definition for a data structure. Abstract Data Types Abstract

More information

Excep&ons and Threads

Excep&ons and Threads Excep&ons and Threads Excep&ons What do you do when a program encounters an anomalous, unusual event? Try to open a file and it's not there Try to convert a string to an integer and it's not a valid integer

More information

More on Objects in JAVA TM

More on Objects in JAVA TM More on Objects in JAVA TM Inheritance : Definition: A subclass is a class that extends another class. A subclass inherits state and behavior from all of its ancestors. The term superclass refers to a

More information

! Instan:a:ng a Group of Product objects. ! InstanEaEng a Group of Friend objects. ! CollecEons can be separated into two categories

! Instan:a:ng a Group of Product objects. ! InstanEaEng a Group of Friend objects. ! CollecEons can be separated into two categories The need for Generic Types class Group Describing the need by example: Define a Group class that stores and manages a group of objects. We can define Group to store references to the Object class

More information

Exceptions and Design

Exceptions and Design Exceptions and Exceptions and Table of contents 1 Error Handling Overview Exceptions RuntimeExceptions 2 Exceptions and Overview Exceptions RuntimeExceptions Exceptions Exceptions and Overview Exceptions

More information

Subclassing for ADTs Implementation

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

Java. Package, Interface & Excep2on

Java. Package, Interface & Excep2on Java Package, Interface & Excep2on Package 2 Package Java package provides a mechanism for par55oning the class name space into more manageable chunks Both naming and visibility control mechanism Define

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 30 November 13, 2015 ExcepEons / IO Chapter 27 HW7: PennPals Chat Due: Tuesday, November 17 th Announcements Start today if you haven't already! Poll

More information

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

Implementing a List in Java. CSE 143 Java. Just an Illusion? List Interface (review) Using an Array to Implement a List.

Implementing a List in Java. CSE 143 Java. Just an Illusion? List Interface (review) Using an Array to Implement a List. Implementing a List in Java CSE 143 Java List Implementation Using Arrays Reading: Ch. 13 Two implementation approaches are most commonly used for simple lists: Arrays Linked list Java Interface List concrete

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 07: Linked Lists and Iterators MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Linked Lists 2 Introduction Linked List Abstract Data Type General Implementation of the ListADT

More information

CS 151. Linked Lists, Recursively Implemented. Wednesday, October 3, 12

CS 151. Linked Lists, Recursively Implemented. Wednesday, October 3, 12 CS 151 Linked Lists, Recursively Implemented 1 2 Linked Lists, Revisited Recall that a linked list is a structure that represents a sequence of elements that are stored non-contiguously in memory. We can

More information

CMSC 341 Lecture 7 Lists

CMSC 341 Lecture 7 Lists CMSC 341 Lecture 7 Lists Today s Topics Linked Lists vs Arrays Nodes Using Linked Lists Supporting Actors (member variables) Overview Creation Traversal Deletion UMBC CMSC 341 Lists 2 Linked Lists vs Arrays

More information

CS211 Computers and Programming Matthew Harris and Alexa Sharp July 9, Boggle

CS211 Computers and Programming Matthew Harris and Alexa Sharp July 9, Boggle Boggle If you are not familiar with the game Boggle, the game is played with 16 dice that have letters on all faces. The dice are randomly deposited into a four-by-four grid so that the players see the

More information

Arrays. myints = new int[15];

Arrays. myints = new int[15]; Arrays As you know from COMP 202 (or equivalent), an array is a data structure that holds a set of elements that are of the same type. Each element in the array can be accessed or indexed by a unique number

More information

COMP1008 Exceptions. Runtime Error

COMP1008 Exceptions. Runtime Error Runtime Error COMP1008 Exceptions Unexpected error that terminates a program. Undesirable Not detectable by compiler. Caused by: Errors in the program logic. Unexpected failure of services E.g., file server

More information

COMP 250 Winter generic types, doubly linked lists Jan. 28, 2016

COMP 250 Winter generic types, doubly linked lists Jan. 28, 2016 COMP 250 Winter 2016 5 generic types, doubly linked lists Jan. 28, 2016 Java generics In our discussion of linked lists, we concentrated on how to add or remove a node from the front or back of a list.

More information

CS/ENGRD 2110 SPRING Lecture 7: Interfaces and Abstract Classes

CS/ENGRD 2110 SPRING Lecture 7: Interfaces and Abstract Classes CS/ENGRD 2110 SPRING 2019 Lecture 7: Interfaces and Abstract Classes http://courses.cs.cornell.edu/cs2110 1 Announcements 2 A2 is due Thursday night (14 February) Go back to Lecture 6 & discuss method

More information

8 Hiding Implementation Details

8 Hiding Implementation Details Object-Oriented Design Lecture 8 CS 3500 Spring 2011 (Pucella) Friday, Feb 4, 2011 8 Hiding Implementation Details Last time we saw the Interpreter Design Pattern as a rather mechanical way to get an implementation

More information

Programming Languages and Techniques (CIS120e)

Programming Languages and Techniques (CIS120e) Programming Languages and Techniques (CIS120e) Lecture 25 Nov. 8, 2010 ExcepEons and the Java Abstract Stack Machine Announcements Homework 8 (SpellChecker) is due Nov 15th. Midterm 2 is this Friday, November

More information

CSE 143X. Accelerated Computer Programming I/II

CSE 143X. Accelerated Computer Programming I/II Adam Blank Lecture 12a Autumn 2015 CSE 143X Accelerated Computer Programming I/II CSE 143X: Accelerated Computer Programming I/II Linked Lists I Outline 1 Learn how LinkedIntList is implemented 2 Learn

More information

Implementing a List in Java. CSE 143 Java. List Interface (review) Just an Illusion? Using an Array to Implement a List.

Implementing a List in Java. CSE 143 Java. List Interface (review) Just an Illusion? Using an Array to Implement a List. Implementing a List in Java CSE 143 Java List Implementation Using Arrays Reading: Ch. 22 Two implementation approaches are most commonly used for simple lists: Arrays Linked list Java Interface List concrete

More information

Data abstractions: ADTs Invariants, Abstraction function. Lecture 4: OOP, autumn 2003

Data abstractions: ADTs Invariants, Abstraction function. Lecture 4: OOP, autumn 2003 Data abstractions: ADTs Invariants, Abstraction function Lecture 4: OOP, autumn 2003 Limits of procedural abstractions Isolate implementation from specification Dependency on the types of parameters representation

More information

Java Review: Objects

Java Review: Objects Outline Java review Abstract Data Types (ADTs) Interfaces Class Hierarchy, Abstract Classes, Inheritance Invariants Lists ArrayList LinkedList runtime analysis Iterators Java references 1 Exam Preparation

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

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

CS260 Intro to Java & Android 03.Java Language Basics

CS260 Intro to Java & Android 03.Java Language Basics 03.Java Language Basics http://www.tutorialspoint.com/java/index.htm CS260 - Intro to Java & Android 1 What is the distinction between fields and variables? Java has the following kinds of variables: Instance

More information

16 Multiple Inheritance and Extending ADTs

16 Multiple Inheritance and Extending ADTs Object-Oriented Design Lecture 16 CS 3500 Fall 2009 (Pucella) Tuesday, Nov 10, 2009 16 Multiple Inheritance and Extending ADTs We looked last time at inheritance and delegation as two ways to reuse implementation

More information

The Java Collections Framework and Lists in Java Parts 1 & 2

The Java Collections Framework and Lists in Java Parts 1 & 2 The Java Collections Framework and Lists in Java Parts 1 & 2 Chapter 9 Chapter 6 (6.1-6.2.2) CS 2334 University of Oklahoma Brian F. Veale Groups of Data Data are very important to Software Engineering

More information

CMPSCI 187: Programming With Data Structures. Lecture 12: Implementing Stacks With Linked Lists 5 October 2011

CMPSCI 187: Programming With Data Structures. Lecture 12: Implementing Stacks With Linked Lists 5 October 2011 CMPSCI 187: Programming With Data Structures Lecture 12: Implementing Stacks With Linked Lists 5 October 2011 Implementing Stacks With Linked Lists Overview: The LinkedStack Class from L&C The Fields and

More information

Logistics. Final Exam on Friday at 3pm in CHEM 102

Logistics. Final Exam on Friday at 3pm in CHEM 102 Java Review Logistics Final Exam on Friday at 3pm in CHEM 102 What is a class? A class is primarily a description of objects, or instances, of that class A class contains one or more constructors to create

More information

CSE 143. Lecture 7: Linked List Basics reading: 16.2

CSE 143. Lecture 7: Linked List Basics reading: 16.2 CSE 143 Lecture 7: Linked List Basics reading: 16.2 References vs. objects variable = value; a variable (left side of = ) is an arrow (the base of an arrow) a value (right side of = ) is an object (a box;

More information

Java Programming Unit 7. Error Handling. Excep8ons.

Java Programming Unit 7. Error Handling. Excep8ons. Java Programming Unit 7 Error Handling. Excep8ons. Run8me errors An excep8on is an run- 8me error that may stop the execu8on of your program. For example: - someone deleted a file that a program usually

More information

Object-Oriented Design Lecture 11 CS 3500 Spring 2010 (Pucella) Tuesday, Feb 16, 2010

Object-Oriented Design Lecture 11 CS 3500 Spring 2010 (Pucella) Tuesday, Feb 16, 2010 Object-Oriented Design Lecture 11 CS 3500 Spring 2010 (Pucella) Tuesday, Feb 16, 2010 11 Polymorphism The functional iterator interface we have defined last lecture is nice, but it is not very general.

More information

Queues. CITS2200 Data Structures and Algorithms. Topic 5

Queues. CITS2200 Data Structures and Algorithms. Topic 5 CITS2200 Data Structures and Algorithms Topic 5 Queues Implementations of the Queue ADT Queue specification Queue interface Block (array) representations of queues Recursive (linked) representations of

More information

About this exam review

About this exam review Final Exam Review About this exam review I ve prepared an outline of the material covered in class May not be totally complete! Exam may ask about things that were covered in class but not in this review

More information

method method public class Temperature { public static void main(string[] args) { // your code here } new

method method public class Temperature { public static void main(string[] args) { // your code here } new Methods Defining Classes and Methods (Savitch, Chapter 5) TOPICS Java methods Java objects Static keyword Parameter passing Constructors A method (a.k.a. func2on, procedure, rou2ne) is a piece of code

More information

CS/ENGRD 2110 SPRING 2018

CS/ENGRD 2110 SPRING 2018 CS/ENGRD 2110 SPRING 2018 Lecture 7: Interfaces and http://courses.cs.cornell.edu/cs2110 1 2 St Valentine s Day! It's Valentines Day, and so fine! Good wishes to you I consign.* But since you're my students,

More information

COMP 250 Fall inheritance Nov. 17, 2017

COMP 250 Fall inheritance Nov. 17, 2017 Inheritance In our daily lives, we classify the many things around us. The world has objects like dogs and cars and food and we are familiar with talking about these objects as classes Dogs are animals

More information

Principles of Software Construction: Objects, Design, and Concurrency. Objects (continued) toad. Spring J Aldrich and W Scherlis

Principles of Software Construction: Objects, Design, and Concurrency. Objects (continued) toad. Spring J Aldrich and W Scherlis Principles of Software Construction: Objects, Design, and Concurrency Objects (continued) toad Spring 2012 Jonathan Aldrich Charlie Garrod School of Computer Science 2012 J Aldrich and W Scherlis Announcements

More information

Arrays. Loops + arrays: challenge problem. Arrays (II) An array is a set of variables of the same type accessed by their index.

Arrays. Loops + arrays: challenge problem. Arrays (II) An array is a set of variables of the same type accessed by their index. Arrays Arrays (Savitch, Chapter 7) TOPICS Array Basics Array Loops Array Programming An array is a set of variables of the same type accessed by their index int[] day = new int[4]; 31 28 31 30 day[0] day[2]

More information

Chapter 6 Introduction to Defining Classes

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

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

More information

The design of an ADT should evolve naturally during the problem-solving process Questions to ask when designing an ADT

The design of an ADT should evolve naturally during the problem-solving process Questions to ask when designing an ADT Designing an ADT The design of an ADT should evolve naturally during the problem-solving process Questions to ask when designing an ADT What data does a problem require? What operations does a problem

More information

CS261 Data Structures. Maps (or Dic4onaries)

CS261 Data Structures. Maps (or Dic4onaries) CS261 Data Structures Maps (or Dic4onaries) Goals Introduce the Map(or Dic4onary) ADT Introduce an implementa4on of the map with a Dynamic Array So Far. Emphasis on values themselves e.g. store names in

More information

CS 31: Intro to Systems Pointers and Memory. Kevin Webb Swarthmore College October 2, 2018

CS 31: Intro to Systems Pointers and Memory. Kevin Webb Swarthmore College October 2, 2018 CS 31: Intro to Systems Pointers and Memory Kevin Webb Swarthmore College October 2, 2018 Overview How to reference the location of a variable in memory Where variables are placed in memory How to make

More information

Assignment3 CS206 Intro to Data Structures Fall Part 1 (50 pts) due: October 13, :59pm Part 2 (150 pts) due: October 20, :59pm

Assignment3 CS206 Intro to Data Structures Fall Part 1 (50 pts) due: October 13, :59pm Part 2 (150 pts) due: October 20, :59pm Part 1 (50 pts) due: October 13, 2013 11:59pm Part 2 (150 pts) due: October 20, 2013 11:59pm Important Notes This assignment is to be done on your own. If you need help, see the instructor or TA. Please

More information

Type Hierarchy. Comp-303 : Programming Techniques Lecture 9. Alexandre Denault Computer Science McGill University Winter 2004

Type Hierarchy. Comp-303 : Programming Techniques Lecture 9. Alexandre Denault Computer Science McGill University Winter 2004 Type Hierarchy Comp-303 : Programming Techniques Lecture 9 Alexandre Denault Computer Science McGill University Winter 2004 February 16, 2004 Lecture 9 Comp 303 : Programming Techniques Page 1 Last lecture...

More information

JAVA BASICS II. Example: FIFO

JAVA BASICS II. Example: FIFO JAVA BASICS II Example: FIFO To show how simple data structures are built without pointers, we ll build a doubly-linked list ListItem class has some user data first refers to that ListItem object at the

More information

Agenda. Excep,ons Object oriented Python Library demo: xml rpc

Agenda. Excep,ons Object oriented Python Library demo: xml rpc Agenda Excep,ons Object oriented Python Library demo: xml rpc Resources h?p://docs.python.org/tutorial/errors.html h?p://docs.python.org/tutorial/classes.html h?p://docs.python.org/library/xmlrpclib.html

More information

COMP 250. Lecture 6. doubly linked lists. Sept. 20/21, 2017

COMP 250. Lecture 6. doubly linked lists. Sept. 20/21, 2017 COMP 250 Lecture 6 doubly linked lists Sept. 20/21, 2017 1 Singly linked list head tail 2 Doubly linked list next prev element Each node has a reference to the next node and to the previous node. head

More information

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L Inheritance Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 9.4 1 Inheritance Inheritance allows a software developer to derive

More information

List ADT. B/W Confirming Pages

List ADT. B/W Confirming Pages wu3399_ch8.qxd //7 :37 Page 98 8 List ADT O b j e c t i v e s After you have read and studied this chapter, you should be able to Describe the key features of the List ADT. the List ADT using an array

More information

Java Programming Unit 7. Error Handling. Collec7ons

Java Programming Unit 7. Error Handling. Collec7ons Java Programming Unit 7 Error Handling. Collec7ons Run7me errors An excep7on is an run- 7me error that may stop the execu7on of your program. For example: - someone deleted a file that your program reads

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

CS61BL Summer 2013 Midterm 2

CS61BL Summer 2013 Midterm 2 CS61BL Summer 2013 Midterm 2 Sample Solutions + Common Mistakes Question 0: Each of the following cost you.5 on this problem: you earned some credit on a problem and did not put your five digit on the

More information

Garbage collec,on Parameter passing in Java. Sept 21, 2016 Sprenkle - CSCI Assignment 2 Review. public Assign2(int par) { onevar = par; }

Garbage collec,on Parameter passing in Java. Sept 21, 2016 Sprenkle - CSCI Assignment 2 Review. public Assign2(int par) { onevar = par; } Objec,ves Inheritance Ø Overriding methods Garbage collec,on Parameter passing in Java Sept 21, 2016 Sprenkle - CSCI209 1 Assignment 2 Review private int onevar; public Assign2(int par) { onevar = par;

More information

CS201 - Assignment 3, Part 2 Due: Wednesday March 5, at the beginning of class

CS201 - Assignment 3, Part 2 Due: Wednesday March 5, at the beginning of class CS201 - Assignment 3, Part 2 Due: Wednesday March 5, at the beginning of class For this assignment we will be developing a text-based Tic Tac Toe game 1. The key to this assignment is that we re going

More information

Encapsula)on, cont d. Polymorphism, Inheritance part 1. COMP 401, Spring 2015 Lecture 7 1/29/2015

Encapsula)on, cont d. Polymorphism, Inheritance part 1. COMP 401, Spring 2015 Lecture 7 1/29/2015 Encapsula)on, cont d. Polymorphism, Inheritance part 1 COMP 401, Spring 2015 Lecture 7 1/29/2015 Encapsula)on In Prac)ce Part 2: Separate Exposed Behavior Define an interface for all exposed behavior In

More information

Implementing a List in Java. CSC 143 Java. List Interface (review) Just an Illusion? Using an Array to Implement a List CSC

Implementing a List in Java. CSC 143 Java. List Interface (review) Just an Illusion? Using an Array to Implement a List CSC Implementing a List in Java CSC 143 Java List Implementation Using Arrays Updated with Java 5.0 Generics Reading: Ch. 13 Two implementation approaches are most commonly used for simple lists: Arrays Linked

More information

Declarations and Access Control SCJP tips

Declarations and Access Control  SCJP tips Declarations and Access Control www.techfaq360.com SCJP tips Write code that declares, constructs, and initializes arrays of any base type using any of the permitted forms both for declaration and for

More information

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved. Java How to Program, 10/e Copyright 1992-2015 by Pearson Education, Inc. All Rights Reserved. Data structures Collections of related data items. Discussed in depth in Chapters 16 21. Array objects Data

More information

List ADT. Announcements. The List interface. Implementing the List ADT

List ADT. Announcements. The List interface. Implementing the List ADT Announcements Tutoring schedule revised Today s topic: ArrayList implementation Reading: Section 7.2 Break around 11:45am List ADT A list is defined as a finite ordered sequence of data items known as

More information

CSE 143 Lecture 26. Advanced collection classes. (ADTs; abstract classes; inner classes; generics; iterators) read 11.1, 9.6, ,

CSE 143 Lecture 26. Advanced collection classes. (ADTs; abstract classes; inner classes; generics; iterators) read 11.1, 9.6, , CSE 143 Lecture 26 Advanced collection classes (ADTs; abstract classes; inner classes; generics; iterators) read 11.1, 9.6, 15.3-15.4, 16.4-16.5 slides created by Marty Stepp, adapted by Alyssa Harding

More information

INTRODUCTION TO DATA AND PROCEDURE

INTRODUCTION TO DATA AND PROCEDURE INTRODUCTION TO DATA AND PROCEDURE In this book, our goal is to understand computation. In particular, we want to be able to take any computational problem and produce a technique for solving it that is

More information

Another interface: Comparable

Another interface: Comparable Another interface: Comparable Comparing things is certainly useful, e.g. for sorting Show me cats ordered by cuteness" Show shapes ordered by number of sides" An example interface: Comparable Since sorting

More information

CS 231 Data Structures and Algorithms, Fall 2016

CS 231 Data Structures and Algorithms, Fall 2016 CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

CSE143 Summer 2008 Final Exam Part B KEY August 22, 2008

CSE143 Summer 2008 Final Exam Part B KEY August 22, 2008 CSE143 Summer 2008 Final Exam Part B KEY August 22, 2008 Name : Section (eg. AA) : TA : This is an open-book/open-note exam. Space is provided for your answers. Use the backs of pages if necessary. The

More information

CH7. LIST AND ITERATOR ADTS

CH7. LIST AND ITERATOR ADTS CH7. LIST AND ITERATOR ADTS ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN JAVA, GOODRICH, TAMASSIA AND GOLDWASSER (WILEY 2016) LISTS LIST ADT A List

More information

1B1b Inheritance. Inheritance. Agenda. Subclass and Superclass. Superclass. Generalisation & Specialisation. Shapes and Squares. 1B1b Lecture Slides

1B1b Inheritance. Inheritance. Agenda. Subclass and Superclass. Superclass. Generalisation & Specialisation. Shapes and Squares. 1B1b Lecture Slides 1B1b Inheritance Agenda Introduction to inheritance. How Java supports inheritance. Inheritance is a key feature of object-oriented oriented programming. 1 2 Inheritance Models the kind-of or specialisation-of

More information

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS Chapter 1 : Chapter-wise Java Multiple Choice Questions and Answers Interview MCQs Java Programming questions and answers with explanation for interview, competitive examination and entrance test. Fully

More information

c) And last but not least, there are javadoc comments. See Weiss.

c) And last but not least, there are javadoc comments. See Weiss. CSCI 151 Spring 2010 Java Bootcamp The following notes are meant to be a quick refresher on Java. It is not meant to be a means on its own to learn Java. For that you would need a lot more detail (for

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

Cloning Enums. Cloning and Enums BIU OOP

Cloning Enums. Cloning and Enums BIU OOP Table of contents 1 Cloning 2 Integer representation Object representation Java Enum Cloning Objective We have an object and we need to make a copy of it. We need to choose if we want a shallow copy or

More information

CSCI 355 LAB #2 Spring 2004

CSCI 355 LAB #2 Spring 2004 CSCI 355 LAB #2 Spring 2004 More Java Objectives: 1. To explore several Unix commands for displaying information about processes. 2. To explore some differences between Java and C++. 3. To write Java applications

More information

ITI Introduction to Computing II

ITI Introduction to Computing II index.pdf March 17, 2013 1 ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Version of March 17, 2013 Definitions A List is a linear abstract

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

CSCI Lab 9 Implementing and Using a Binary Search Tree (BST)

CSCI Lab 9 Implementing and Using a Binary Search Tree (BST) CSCI Lab 9 Implementing and Using a Binary Search Tree (BST) Preliminaries In this lab you will implement a binary search tree and use it in the WorkerManager program from Lab 3. Start by copying this

More information

Soda Machine Laboratory

Soda Machine Laboratory Soda Machine Laboratory Introduction This laboratory is intended to give you experience working with multiple queue structures in a familiar real-world setting. The given application models a soda machine

More information

Rules and syntax for inheritance. The boring stuff

Rules and syntax for inheritance. The boring stuff Rules and syntax for inheritance The boring stuff The compiler adds a call to super() Unless you explicitly call the constructor of the superclass, using super(), the compiler will add such a call for

More information

Prelim 1. CS 2110, March 15, 2016, 5:30 PM Total Question Name True False. Short Answer

Prelim 1. CS 2110, March 15, 2016, 5:30 PM Total Question Name True False. Short Answer Prelim 1 CS 2110, March 15, 2016, 5:30 PM 0 1 2 3 4 5 Total Question Name True False Short Answer Object- Oriented Recursion Loop Invariants Max 1 20 14 25 19 21 100 Score Grader The exam is closed book

More information

ADT Unsorted List. Outline

ADT Unsorted List. Outline Chapter 3 ADT Unsorted List Fall 2017 Yanjun Li CS2200 1 Outline Abstract Data Type Unsorted List Array-based Implementation Linked Implementation Comparison Fall 2017 Yanjun Li CS2200 2 struct NodeType

More information

Practice Questions for Final Exam: Advanced Java Concepts + Additional Questions from Earlier Parts of the Course

Practice Questions for Final Exam: Advanced Java Concepts + Additional Questions from Earlier Parts of the Course : Advanced Java Concepts + Additional Questions from Earlier Parts of the Course 1. Given the following hierarchy: class Alpha {... class Beta extends Alpha {... class Gamma extends Beta {... In what order

More information

EMBEDDED SYSTEMS PROGRAMMING OO Basics

EMBEDDED SYSTEMS PROGRAMMING OO Basics EMBEDDED SYSTEMS PROGRAMMING 2014-15 OO Basics CLASS, METHOD, OBJECT... Class: abstract description of a concept Object: concrete realization of a concept. An object is an instance of a class Members Method:

More information

CS 251 Intermediate Programming Inheritance

CS 251 Intermediate Programming Inheritance CS 251 Intermediate Programming Inheritance Brooke Chenoweth University of New Mexico Spring 2018 Inheritance We don t inherit the earth from our parents, We only borrow it from our children. What is inheritance?

More information

Stage 11 Array Practice With. Zip Code Encoding

Stage 11 Array Practice With. Zip Code Encoding A Review of Strings You should now be proficient at using strings, but, as usual, there are a few more details you should know. First, remember these facts about strings: Array Practice With Strings are

More information

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

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

More information

More on collec)ons and sor)ng

More on collec)ons and sor)ng More on collec)ons and sor)ng CSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2013 Java Collec/ons API Overview List (last term), e.g. ArrayList Map (last /me), e.g. HashMap Set

More information

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

Day 8. COMP1006/1406 Summer M. Jason Hinek Carleton University Day 8 COMP1006/1406 Summer 2016 M. Jason Hinek Carleton University today s agenda assignments Assignment 4 is out and due on Tuesday Bugs and Exception handling 2 Bugs... often use the word bug when there

More information

University of Utah School of Computing

University of Utah School of Computing University of Utah School of Computing CS 1410 / CS 2000 Study Notes December 10, 2011 This study guide is designed to help you prepare and study the appropriate material for the final exam. For the multiple

More information

Arrays. Array Definition

Arrays. Array Definition Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Arrays Arrays 1 Array Definition An array

More information

Lecture Topics. Administrivia

Lecture Topics. Administrivia ECE498SL Lec. Notes L8PA Lecture Topics overloading pitfalls of overloading & conversions matching an overloaded call miscellany new & delete variable declarations extensibility: philosophy vs. reality

More information

CS 151. Exceptions & Javadoc. slides available on course website. Sunday, September 9, 12

CS 151. Exceptions & Javadoc. slides available on course website. Sunday, September 9, 12 CS 151 Exceptions & Javadoc slides available on course website 1 Announcements Prelab 1 is due now. Please place it in the appropriate (Mon vs. Tues) box. Please attend lab this week. There may be a lecture

More information

The list abstract data type defined a number of operations that all list-like objects ought to implement:

The list abstract data type defined a number of operations that all list-like objects ought to implement: Chapter 7 Polymorphism Previously, we developed two data structures that implemented the list abstract data type: linked lists and array lists. However, these implementations were unsatisfying along two

More information

Introduction to Computing II (ITI 1121) Final Examination

Introduction to Computing II (ITI 1121) Final Examination Université d Ottawa Faculté de génie École de science informatique et de génie électrique University of Ottawa Faculty of Engineering School of Electrical Engineering and Computer Science Introduction

More information

Administration. Exceptions. Leftovers. Agenda. When Things Go Wrong. Handling Errors. CS 99 Summer 2000 Michael Clarkson Lecture 11

Administration. Exceptions. Leftovers. Agenda. When Things Go Wrong. Handling Errors. CS 99 Summer 2000 Michael Clarkson Lecture 11 Administration Exceptions CS 99 Summer 2000 Michael Clarkson Lecture 11 Lab 10 due tomorrow No lab tomorrow Work on final projects Remaining office hours Rick: today 2-3 Michael: Thursday 10-noon, Monday

More information