| CIT591 Final Exam Fall, 2003 |
Name_________________________________________ |
Please keep all your answers short and to the point. Read the questions carefully and answer only the question that was asked--do not provide extra information that was not asked for.
When I ask for a "single statement," that means one statement that does not contain any other statements.
In your Java code, be sure I can tell the difference between your lowercase letters and your CAPITAL LETTERS.
5L ? x % y give a negative result? ^ operator (as in, x ^ y)
perform? new Color(0, 0, 255)?String s;),
what is space allocated for?Error? printStackTrace() put its output?Random class?Observer interface?ActionListener interface? .class files) ?Component that is also a Container.ch is a char variable, containing a letter
in the first part of the alphabet. Write a single statement to change ch
to be the next consecutive character (for example, if ch has
value 'e', your statement will change it to have value 'f').5 lines
if the value of lineCount is 5, but will print out 1 line
if the value of lineCount is 1. x to the
numeric value of s, where s is a String that contains
only digits.for loops to print out all the values
in the array defined by int[][] rag = { {1}, {2, 3}, {4, 5, 6} };
Each row should be printed on a separate line.public class CallTest {
public static void main(String[] args) {
int n = 5;
int[] a = new int[] {1, 2, 3};
modify(n, a);
System.out.println(n + " " + a[0] + a[1] + a[2]);
}
static void modify(int x, int[] y) {
x++;
y[1] = x;
}
}
this
or super in your explanation (for example, for that=this;
don't say "assigns this to that").that = this;
this();
super();
super.that();
that(this);
public class Test {
String instVar;
static String statVar = "A";
Test() {
System.out.println("test: " + instVar + statVar);
instVar = "B"; statVar = "C";
}
public static void main(String[] args) {
Test t1 = new Test();
t1.instVar = "D";
t1.statVar = "E";
Test t2 = new Test();
System.out.println("inst: " + t1.instVar + t2.instVar);
System.out.println("stat: " + t1.statVar + t2.statVar);
}
}
int i = 5;
while (i > 0);
System.out.println(i--);
System.out.println("Blast off!");
interface is automatically
both _______________ and _______________ (two keywords).Foo, where
class Foo { int x = 5; int y; Foo() { x = 2; } }, x and y in the new object?instanceof
operator. x %= y; that
does not use the %= operator. x ^ y return
true?class Foo implements Runnable and contains a
run() method, write the code necessary to start an object of this class
running in a new thread.vec is a Vector and x
is an int, both the following statements are wrong. Correct them.vec.add(x);x = vec[0];int
array, counts how many elements are "out of place." An element is
"out of place" if it is larger than the element that follows it.this.