39-pop-quiz

39-pop-quiz - CS 106A Handout #34 August 12, 2009 CS106a...

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

View Full Document Right Arrow Icon
Handout #34 CS 106A August 12, 2009 CS106a Pop Quiz 1. Write a program that reads numbers from a user (until they enter 0), and keeps multiplying the numbers entered. public void run() { 2. Write a method that takes in two integers, and returns the maximum of the two.
Background image of page 1

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

View Full DocumentRight Arrow Icon
3. If we ran each of the 3 programs below in turn, what would be printed? public class Program1 extends ConsoleProgram { public void run() { int x = 5; foo(x); println(x); } private void foo(int num) { num = 4; int x = 4; } } public class Program2 extends ConsoleProgram { public void run() { GOval cir = new GOval(0, 0, 100, 100); foo(cir); println(cir.getX()); } private void foo(Goval oval) { oval.setLocation(5, 5); } } public class Program3 extends ConsoleProgram { public void run() { String name = “Brandon”; foo(name); println(name); } private void foo(String name) { name = name.substring(0, 3); } }
Background image of page 2
4. For each of the following variables in a Breakout program, write I if you think it should be an instance variable, L for local variable. private GOval ball;
Background image of page 3

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

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

Page1 / 5

39-pop-quiz - CS 106A Handout #34 August 12, 2009 CS106a...

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

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