| CIT591 Midterm Exam Fall, 2004 |
Name_________________________________________ |
Please keep all your answers short and to the point. Do not provide extra information that was not asked for.
|
|
String s = "^(^12^3^,-4^56^^)".replaceAll("^", "");
int i = s.indexOf(",");
String first = s.substring(1, i);
int number1 = new Integer(first).intValue();
String second = s.substring(i + 1, s.length() - 2);
int number2 = new Integer(second).intValue();
|
// Declare the class
// Write the header for the main method
// Declare an integer variable "number"
// Set the number to a value gotten from the command line (args[0])
// Begin a loop whose test is at the bottom
// Print the current value of "number"
// If the number is even...
// Divide it by 2
// But if the number is odd...
// Multiply it by 3 and subtract 1
// Exit the loop if the number is 1
// End the method and the program
|
private Fiddle(int x) {
super(x + 1);
. . . }39FF
?
|
|
int n = Foo.bar().length();
in a program. Classify each of the following statements as true (T),
probably true (P),
unlikely (U),
or false (F):
bar() is a static method of Foo.bar() is defined in class Foo.Foo.bar() returns a String as a result.Foo.bar(x).length() returns an int result.protected classes are accessible from more places
than "package" classes.m is an int[], then m instanceof
Object is true. .java file may contain only one class. .java file may contain only one public class.private constructor can never be used.private class can never be used for anything.