MidTerm1F08 - 1/7 EE 322C Fall 2008 First Mid-Term Dr....

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

View Full Document Right Arrow Icon
1/7 EE 322C Fall 2008 First Mid-Term Dr. Ramesh Yerraballi Full Name : Quiz Duration : 75 minutes 1. [ 20 points ] Answer the following i. [ 4 points ] In the method below, which statement about the possible output is correct? public static void what( ) { int x = 5; f( x ); // Some function whose code does not matter System.out.println( x ); } a. 0 is a possible output b. 5 is the only possible output c. Any integer can be output d. None of the above are true ii. [ 12 points ] What is the value of a, b and c after each of the following lines: [Note: The answers on one line affect the values on the next] int a = 5, b = 8, c = 0; a = b++ + c++; //Answer: a:____ b:____ c:____ a = b++ + ++c; //Answer: a:____ b:____ c:____ a = ++b + c++; //Answer: a:____ b:____ c:____ a = ++b + ++c; //Answer: a:____ b:____ c:____ iii. [ 4 points ] What does the method below do? [Hint: Eliminate the wrong answers] public static int foo(String [] Strs) { int t = 0; for( int i=0; i < Strs.length; i++ ) t += Strs[i].length(); return t; } a. Returns the sum of the lengths of all the strings in the array of Strings passed as a parameter b. Returns the concatenation of all the strings in the array of Strings passed as a parameter c. Returns the concatenation of all the string in the array of Strings passed as a parameter, in reversed order (last string first) d. Generates a compiler error because Strs.length does not make sense
Background image of page 1

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

View Full DocumentRight Arrow Icon
2/7 2. [ 20 points ] Given the following class X and a class useX that uses the class X : public class X { static int sta = 0; private int pri; public int pub; public X(int pr, int pu) { pri = pr; pub = pu; sta++; } public void sw()
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.

Page1 / 7

MidTerm1F08 - 1/7 EE 322C Fall 2008 First Mid-Term Dr....

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

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