Slide 1

Slide 1 text

CSE110 Principles of Programming with Java Lecture 31: Review Javier Gonzalez-Sanchez [email protected] javiergs.engineering.asu.edu | javiergs.com Office Hours: By appointment

Slide 2

Slide 2 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 2 Disclaimer The following questions are just examples. They are NOT a comprehensive list of topics Review All the Slides for a full list of topics The exam is NOT limited to the topics covered in this review. Midterm Exams are comprehensive

Slide 3

Slide 3 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 3 Midterm 1

Slide 4

Slide 4 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 4 Midterm 2

Slide 5

Slide 5 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 5 Midterm 3 19. Constructor 20. Null and This 21. Practice 22. Arrays I 23. Arrays II 24. References 25. References II 26. Recursion 27. Searching 28. Sorting and Review

Slide 6

Slide 6 text

Getting everything together

Slide 7

Slide 7 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 7 Case 1 Step by step: {6, 3, 0, 5, 1} {3, 6, 0, 5, 1} {3, 0, 6, 5, 1} {3, 0, 5, 6, 1} {3, 0, 5, 1, 6} {0, 3, 5, 1, 6} {0, 3, 5, 1, 6} {0, 3, 5, 1, 6} {0, 3, 1, 5, 6} {0, 3, 1, 5, 6} {0, 1, 3, 5, 6} {0, 1, 3, 5, 6}

Slide 8

Slide 8 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 8 Case 1 Step by step: {6, 3, 0, 5, 1} {3, 6, 0, 5, 1} {3, 0, 6, 5, 1} {3, 0, 5, 6, 1} {3, 0, 5, 1, 6} {0, 3, 5, 1, 6} {0, 3, 5, 1, 6} {0, 3, 5, 1, 6} {0, 3, 1, 5, 6} {0, 3, 1, 5, 6} {0, 1, 3, 5, 6} {0, 1, 3, 5, 6} public static void bubbleSort(int[] ar) { int tmp; for(int p1=0; p1 < ar.length-1; p1++){ for (int p2=0; p2 < ar.length-1-p1; p2++){ if (ar[p2] > ar[p2+1]){ tmp = array[p2]; array[p2] = array[p2+1]; array[p2+1] = tmp; } } } }

Slide 9

Slide 9 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 9 Case 2 Searching and Sorting Arrays of Objects John Mary Alice Robert 4 1 3 2

Slide 10

Slide 10 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 10 Case 3 • A two-dimensional array can be thought of as a table of elements, with rows and columns 0 1 2 3 4 5 int [][]array = new int [6][3] array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2

Slide 11

Slide 11 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 11 Case 3 with Code

Slide 12

Slide 12 text

Test Yourselves

Slide 13

Slide 13 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 13 Question

Slide 14

Slide 14 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 14 Question

Slide 15

Slide 15 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 15 Question

Slide 16

Slide 16 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 16 Question

Slide 17

Slide 17 text

Topics By Day

Slide 18

Slide 18 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 18 Lecture 19 • Constructor, default Constructor, multiple constructors • The toString method • What is encapsulation? • Modifiers public and private • getters • setters

Slide 19

Slide 19 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 19 Lecture 20 • null • NullPointerException • this • static and not static

Slide 20

Slide 20 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 20 Lecture 21

Slide 21

Slide 21 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 21 Lecture 22 • Create arrays • Arrays of Primitive types • Arrays of Objects • Default values • Index: 0 to n-1 and ArrayIndexOutOfBoundsException type name [ ] = new type [size]

Slide 22

Slide 22 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 22 Lecture 23 • length variable • for-loop to show data, add data, etc. • Initializer lists type [] name = { value, value, value, …}

Slide 23

Slide 23 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 23 Lecture 24 • References (pointers) • References to Objects • References to Arrays • Arrays of Objects • Objects with Arrays as attributes

Slide 24

Slide 24 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 24 Lecture 25 • Parameters using References (pointers) • Objects as Parameters • Arrays as Parameters • Arrays of Objects as Parameters • Objects with Arrays as Parameters

Slide 25

Slide 25 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 25 Lecture 26 Recursion • How does it work • Understand factorial. Fibonacci, Searching, etc. • What about print numbers n to m? • What about add numbers 0 to n?

Slide 26

Slide 26 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 26 Lecture 27, 28 Searching • Linear Search • Binary Search Sorting • Bubble Sort • Selection Sort

Slide 27

Slide 27 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 27 Disclaimer The following questions are just examples. They are NOT a comprehensive list of topics Review All the Slides for a full list of topics The exam is NOT limited to the topics covered in this review. Midterm Exams are comprehensive

Slide 28

Slide 28 text

CSE110 - Principles of Programming Javier Gonzalez-Sanchez [email protected] Summer 2020 Disclaimer. These slides can only be used as study material for the class CSE110 at ASU. They cannot be distributed or used for another purpose.