Exam2 - Name: _ Midterm 2 CS 5JA Spring 2008 Short Answer:...

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

View Full Document Right Arrow Icon
Name: ________________________ Midterm 2 CS 5JA Spring 2008 Short Answer: _____/29 Output: _____/19 Programming: _____/20 Total: _____/68
Background image of page 1

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

View Full DocumentRight Arrow Icon
(21)Given the following declarations, what is the value of each expression? int x = 2; int y[] = {3,1,0,7,2,4,8,6}; int z[] = {1,4,7,2,0,3,5,9,6}; String name = “Johnathan Hernandez”; Expression Value or Explanation y[5] z[x] z[y[x]] y[x]+4 y[x+4] name.charAt(3); name.contains(“and”); (4) I am trying to decide what looping structure to choose. I am guaranteed the loop will execute at least once, but I have no way of knowing how many times it will execute. What is the most appropriate loop? (2) Explain what argument promotion is. (2) In the space below, copy the line of code that involves casting from the last page of the test.
Background image of page 2
(9)What is the output of the following program? I have abbreviated “System.out” to S.o public class X { public static void main(String args[]) { int var = 7; Y myY = new Y(5); var = myY.a(); S.o.printf(“a: %d\n”,var);
Background image of page 3

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

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

Page1 / 4

Exam2 - Name: _ Midterm 2 CS 5JA Spring 2008 Short Answer:...

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

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