Homework 1 CS110 Due February 3 2006 5 points per problem 1 Given int n 1 m 2 l 3 double x 5 0 y 4 0 Which of the following assignments are valid If an assignment is not valid state the reason If the assignment is valid show the result of the calculation a b c d e f n m 5 x 2 n 5 3 n x 5 x y x y x x 5 n 3 4 6 2 Suppose x y z and w are int variables What value is assigned to each variable after the last statement executes x 5 z 3 y x z z 2 y 3 w x 2 y z z w x w 3 The following program has syntax mistakes Indicate and Correct them On each successive line assume that any preceding error has been corrected public class ProgWithErrorsA public void main String args final int PRIME 11 213 final int RATE 15 6 int i x y w x 7 y 3 x x w PRIME x PRIME system out println PRIME wages rate 36 75 system out println wages wages 4 Suppose a b and c are int variables and a 5 and b 6 What value is assigned to each variable after each statement executes If a variable is undefined at a particular statement report it as UND undefined a b 3 c 2 a b b 2 c a 5 Write a program that prompts the user to input five decimal numbers The program should then add the five numbers and convert the sum to an integer and print the result 6 How does a variable of a primitive type differ from a reference variable
View Full Document
Unlocking...