Spring 2023 Lesson - CSE 121 Announcements, Reminders, and Poll

cse 121 lesson 17 n.w
1 / 8
Embed
Share

Explore the latest announcements, reminders, and polls for the Spring 2023 session of CSE 121. Get information on due dates, retake opportunities, final exam schedule, and more. Dive into the concepts of value semantics vs. reference semantics with interactive examples. Stay updated with important information and engage in a quiz to test your understanding. Join the vibrant academic community and stay informed about the upcoming events in this dynamic lesson.

  • CSE 121
  • Spring 2023
  • Announcements
  • Poll
  • Value Semantics

Uploaded on | 1 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 17 Miya Natsuhara Spring 2023 Music: 121 23sp Lecture Vibes TAs: Jasmine Shananda Vidhi Larry Jacqueline Afifah Atharva Julia Anju Lydia Jonus Hugh Mia Archit Grace Kailye Joshua James Justin Aishah Claire Lydia Kai sli.do #cse121

  2. Announcements, Reminders P3 due Wednesday, May 31 11:59pm Retake form for 5/30 will be released later today Only Quiz 2 is eligible Last retake opportunity of the quarter Gumball (& friends) Visit on Monday, June 5 1:00pm-3:00pm Final Exam: Thursday, June 8 2:30pm-4:20pm Left-Handed Seating Request form posted on Ed and closes Mon 5/29 EOD TA-led Final Review Session Tuesday, June 6 4:30pm-7:00pm Bob Bandes TA Award Nominations Open! Lesson 17 - Spring 2023 2

  3. 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} Lesson 17 - Spring 2023 3

  4. (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 Lesson 17 - Spring 2023 4

  5. (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; Lesson 17 - Spring 2023 5

  6. (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]; } } Lesson 17 - Spring 2023 6

  7. 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)); } Lesson 17 - Spring 2023 7

  8. 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)); } Lesson 17 - Spring 2023 8

Related


More Related Content