{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

t1sp04 - CS100J 2004 Spring Surname First name Prelim 1...

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

View Full Document Right Arrow Icon
CS100J 2004 Spring Prelim 1 Feb 26, 2004, 7:30-9:00pm Surname , First name Middle name Name: _____________________________________________________ CU NetID: __________ Statement of integrity: I did not, and will not, violate the rules of academic integrity on this exam. _______________________________________________________________________________ (Signature) Circle your lecture time: 9:05 or 11:15 Q1: ______ 25pts ____ Q2: ______ 25pts ____ Q3: ______ 20pts ____ Q4: ______ 30pts ____ Total: ______ 100pts ____ Instructions: This is a 90-minute, closed-book exam; no calculators are allowed. There are 4 questions worth a total of 100 points A rough time budget: Try not to spend more than 18 minutes on a 20-point question. Raise your hand if you have any questions. Use the backs of pages or ask for additional sheets of paper as necessary. Clarity, conciseness, and style count for credit. If you supply multiple answers, we will grade only one . Use only Java code. No credit for code written in other programming languages. Do not use switch , break , or System.exit statements. Do not use arrays. 1
Background image of page 1

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

View Full Document Right Arrow Icon
Question 1: (25 points) Part (a): (7 points) Write in the box on the right the output that will be produced by executing the following program. public class Q1a { Output public static void main(String[] args) { int n=3, p=6; int w= junk(p); System.out.println(“w is ” + w); System.out.println(“n is ” + n); System.out.println(“p is ” + p); } public static int junk(int n) { int p=1; n= n + p; System.out.println(“n is ” + n); System.out.println(“p is ” + p);
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}