stats61b - Sheet1 Page 1 Autumn 2006 Johnathan Shewchuk CS...

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: Sheet1 Page 1 Autumn 2006 Johnathan Shewchuk CS 61B: Midterm Exam I This is an open book, open notes exam. Electronic devices are forbidden on your person, including cell phones, iPods, headphones, and PDAs. Turn your cell phone off and leave all electronics except your laptop, with the instructor, or risk getting a zero on the exam. Do not open your exam until you are told to do so! t Problem 1. (6 points) Java bugs. After you finished studying late last night, you fell into a fitful sleep and dreamt the following code. Unfortunately, you wrote four buggy lines. Fix them, so that all three methods work correctly. Each fix should involve changing just part of a line of code. The fact that everything is public does not count as a bug. public class Quantity { public String thing public double amount // Constructor. public Quantity(String thingString, double amount) { thing = thingString amount = amount } // Constructor for thing with quantity 100. Calls the other constructor. public Quantity(String thingString) { Quantity(thingString, 100.0) } public static void main(String args){ System.out.println(this.thing + this.amount)System....
View Full Document

This note was uploaded on 07/11/2009 for the course CEE cee taught by Professor Monteiro during the Fall '05 term at University of California, Berkeley.

Page1 / 8

stats61b - Sheet1 Page 1 Autumn 2006 Johnathan Shewchuk CS...

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