Programming Assignments and Exam Schedule for CSE.121 Summer 2023

Programming Assignments and Exam Schedule for CSE.121 Summer 2023
Slide Note
Embed
Share

CSE.121 Lesson 12 announcements cover Programming Assignment due dates, the Final Exam schedule, left-handed seating requests, and important topics such as File I/O, Arrays, and Reference Semantics. Learn about arrays elements, traversal patterns, and value semantics versus reference semantics. Engage in polls to test your understanding of array manipulation and variable behaviors. Stay updated on the upcoming quiz, assignment submissions, and exam preparation strategies.

  • Programming
  • CSE.121
  • Summer 2023
  • Arrays
  • Exam Schedule

Uploaded on Apr 13, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. CSE 121 Lesson 12 Kai Daniels Summer 2023 Music: k-pop girlies playlist sli.do #cse121

  2. Announcements, Reminders Programming Assignment 2 due yesterday, Programming Assignment 3 Its Data Time out later today due next Tuesday C3 will be a take home final Resub 4 due tomorrow Quiz 2 (Take-home): Monday Aug 7th(8/7) Topics: File I/O (Scanner, PrintStream), Arrays, Reference Semantics Reminder: Final exam Wednesday Aug 16 4:30 6:30 PM in PAA A102 Left-Handed Seating Request form posted on Ed due Aug 7th EOD 2

  3. (PCM) Arrays Elements (must all be the same type) Indices (starting at 0) Must decide size when created arr.length to get arr's length Arrays.toString(arr) to get a nice String version 3

  4. (PCM) Array Traversal Pattern for (int i = 0; i < arr.length; i++) { // do something with arr[i] } 4

  5. Poll in with your answer! How can we get the last element of an array arr? A.arr[arr.length()] B.arr[length()] C.arr[arr.length] D.arr[arr.length() -1] E.arr[arr.length - 1] 5

  6. Poll in with your answer! What would the array a store at the end of this arrayMystery method if {-20, 20, 26, 32, 50, 3} was passed in? A.{-20, 20, 26, 32, 50, 3} B.{-15, 25, 31, 37, 55, 8} C.{-15, 25, 31, 37, 50, 3} D.{-15, 20, 26, 37, 50, 3} 6

  7. (PCM) Value Semantics vs. Reference Semantics Applies when working with primitive types Applies when working with objects Variables/parameters hold a copy of the actual value Variables/parameters hold a reference to the object 7

  8. (PCM) Value Semantics vs. Reference Semantics int[] list1 = {4, 8, 15, 16, 23}; int[] list2 = list1; int a = 3; int b = a; a = 99; list1[1] = 99; 8

  9. (PCM) Value Semantics vs. Reference Semantics boolean test = true; boolean[] tests = flipValue(test); {true, true, false, true, false, false}; flipValues(tests); public static void flipValue(boolean b) { b = !b; public static void flipValues(boolean[] b) { } for (int i = 0; i < b.length; i++) { b[i] = !b[i]; } } 9

  10. Poll in with your answer! public static void main(String[] args) { int x = 0; int[] a = new int[4]; x++; mystery(x, a); System.out.println(x + " " + Arrays.toString(a)); Four lines of output would be produced by this code. What would those four lines be? x++; mystery(x, a); System.out.println(x + " " + Arrays.toString(a)); } public static void mystery(int x, int[] a) { x++; a[x]++; System.out.println(x + " " + Arrays.toString(a)); } 10

  11. Poll in with your answer! public static void main(String[] args) { int x = 0; int[] a = new int[4]; x++; mystery(x, a); System.out.println(x + " " + Arrays.toString(a)); x++; mystery(x, a); System.out.println(x + " " + Arrays.toString(a)); } public static void mystery(int x, int[] a) { x++; a[x]++; System.out.println(x + " " + Arrays.toString(a)); } 11

Related


More Related Content