l2 - a compile-time or a run-time error in the C/R column...

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

View Full Document Right Arrow Icon
CS121 Autumn 2009 Lecture #2 exercises The purpose of these exercises is to allow you to test your understanding of the material covered in today’s lecture. You are welcome to turn in your answers at the next lecture to get feedback from us, but you are not required to do so. These exercises are intended to take less than an hour, assuming you have done the reading. If you cannot Problem 1: Copy the directory /home/amr/cs121/L2 to your cs121 directory. In it, you will find a series of programs named A.java , B.java , etc. These programs are intended to perform the same task. A.java compiles and runs correctly. Some of the remaining programs do not compile, the others compile, but generate an error at runtime. Fill in the following table. For each program, record whether the error has
Background image of page 1

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

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

Unformatted text preview: a compile-time or a run-time error in the C/R column and give the source of the error in the explanation column. This exercise is tedious, but the time you spend learning about how to identify syntax errors, will save you frustration later. Program C/R Explanation B C D E F Problem 2 : For each part, state the value of a (and b ) after evaluating the code fragment. (a) int a = 10/3; (b) boolean a = true; a = !a; a = !a; a = !a; (c) double a; double b = 1.0; double c = 2.0; double d = 3.0; a = 4.0 * b * c/d * d; b = 4.0 * b * c/(d * d); Problem 3: Assuming x and y are declared to be double s. Write an expression to compute x/y 3 . Problem 4: Assume a and b are int s. Write an expression computing whether a is equal to b without using the == or != operators....
View Full Document

Page1 / 2

l2 - a compile-time or a run-time error in the C/R column...

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