20-section-handout-3

20-section-handout-3 - Mehran Sahami CS 106A Handout #20...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Mehran Sahami Handout #20 CS 106A October 15, 2007 Section Handout #3 Parameters, Random Numbers, and Simple Graphics Portions of this handout by Eric Roberts and Patrick Young. 1. True/False questions For each of the following statements below, indicate whether it is true or false in Java: a) The value of a local variable named i has no direct relationship with that of a variable named i in its caller. b) The value of a parameter named x has no direct relationship with that of a variable named x in its caller. 2. Tracing method execution For the program below, trace through its execution by hand to show what output is produced when it runs. /* * File: Hogwarts.java * ------------------- * This program is just testing your understanding of parameter passing. */ import acm.program.*; public class Hogwarts extends ConsoleProgram { public void run() { bludger(2001); } private void bludger(int y) { int x = y / 1000; int z = (x + y); x = quaffle(z, y); println("bludger: x = " + x + ", y = " + y + ", z = " + z);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

20-section-handout-3 - Mehran Sahami CS 106A Handout #20...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online