ISQS 6337 F00 Exam 1 10/5/00

Please follow all class style guidelines. Hungarian notation, indention, neatness of code, simple comments, correct data type definitions and output formatting will all count. You do not need to worry about the program description at the top. If I cannot read it then it is wrong!!! Always be brief where possible.

1. In the space below write a program to fit the flow chart on the following page. (30)


2.  Write a java statement, or set of statements to accomplish the following :

  1. Calculate the value of 2.5 raised to the 5th power using a for loop (8)
  1. Given:
    String sS1 = “Hello”,
    String sS2; // to be filled with user input DO NOT CODE THE INPUT!
    write an if statement print EQUAL on the display if the strings are equal (7)
  1. Given:
    int w, x, y, z; // all assigned values elsewhere in the program
    write a single if statement to test whether or not w is greater than x, x is greater than y, and y is greater than z (5)
  2. Write a method header for a public method named BOB to take two ints and a float as arguments and to return a long. (5)
  3. Write the method call necessary to call the method defined in d. above. (5)

3.  Write a SHORT answer to the following questions.

  1. What is the difference between a Java Application and a Java Applet? (5)
  2. What is the purpose of the private and public words in a method header? (5)
  3. Assume that an Applet is loaded, minimized, maximized again, and then destroyed. In what order are the basic Applet methods called. (10)

4.  What does the following code print if called in main with an argument of 25? (10 points)

public void F1(int iA) {

int j = 0, k = 1;

for (int i=0; i<50;i++) System.out.println(“”);

System.out.print(j + "\t" + k + "\t");

for (int i = 2; i < iA; i++) {

i = j + k; j = k; k = i;

System.out.print(i + "\t");

if (i%5==0) System.out.println();

}

}

5.  Assume you are creating a menu with char choices from A to C. Write a switch statement that displays “Choice A” when A or a is chosen, “Choice B” when B or b is chosen and so forth. Write only the switch compound statement; do not write the user input or loop. (10 points)