public class Foo {
public void main (String args) {
system.out.printIn(“Hello World.”);
}
}
What is the result? ()
A. An exception is thrown.
B. The code does no compile.
C. “Hello World.” Is printed to the terminal.
D. The program exits without printing anything.
您可能感兴趣的试卷
你可能感兴趣的试题
1. public class Test {
2. public static void main (String args) {
3. unsigned byte b = 0;
4. b--;
5.
6. }
7. }
What is the value of b at line 5?()
A. -1
B. 255
C. 127
D. Compilation will fail.
E. Compilation will succeed but the program will throw an exception at line 4.
A. 0 . . . 32767
B. 0 . . . 65535
C. –256 . . . 255
D. –32768 . . . 32767
E. Range is platform dependent.
A. 3/2
B. 3<2
C. 3*4
D. 3<<2
E. 3*2^2
F. 3<<<2
public class Test {
public static void replaceJ(string text) {
text.replace (‘j‘, ‘l‘);
}
public static void main(String args) {
string text = new String (“java”)
replaceJ(text);
system.out.printIn(text);
}
}
What is the result?()
A. The program prints “lava”
B. The program prints “java”
C. An error at line 7 causes compilation to fail.
D. Compilation succeeds but the program throws an exception.
public class Foo {
private int val;
public foo(int v) (val = v;) }
public static void main (String args) {
Foo a = new Foo (10);
Foo b = new Foo (10);
Foo c = a;
int d = 10;
double e = 10.0;
}
Which three logical expression evaluate to true? ()
A. (a ==c)
B. (d ==e)
C. (b ==d)
D. (a ==b)
E. (b ==c)
F. (d ==10.0)
public class Test {
public static void leftshift(int i, int j) {
i<<=j;
}
public static void main(String args) {
int i = 4, j = 2;
leftshift(i, j);
System.out.printIn(i);
}
}
What is the result? ()
A. 2
B. 4
C. 8
D. 16
E. The code will not compile.
public class SyncTest {
private int x;
private int y;
public synchronized void setX (int i) (x=1;)
public synchronized void setY (int i) (y=1;)
public synchronized void setXY(int 1)(set X(i); setY(i);)
public synchronized Boolean check() (return x !=y;)
}
Under which conditions will check () return true when called from a different class?
A. Check() can never return true.
B. Check() can return true when setXY is called by multiple threads.
C. Check() can return true when multiple threads call setX and setY separately.
D. Check() can only return true if SyncTest is changed to allow x and y to be set separately.
public class X implements Runnable(
private int x;
private int y;
public static void main(Stringargs)
X that = new X();
(new Thread(that)).start();
(new Thread(that)).start();
)
public void run() (
for (;;) (
x++;
y++;
System.out.printIn(“x=” + x + “, y = ” + y);
)
)
What is the result?()
A. Errors at lines 7 and 8 cause compilation to fail.
B. The program prints pairs of values for x and y that might not always be the same on the same line (for example, “x=2, y=1”).
C. The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by “x=1, y=1”).
D. The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears only for once (for example, “x=1, y=1” followed by “x=2, y=2”).
A. The elements in the collection are ordered.
B. The collection is guaranteed to be immutable.
C. The elements in the collection are guaranteed to be unique.
D. The elements in the collection are accessed using a unique key.
E. The elements in the collections are guaranteed to be synchronized.
A. Java.util.Map
B. Java.util.Set
C. Java.util.List
D. Java.util.StoredSet
E. Java.util.StoredMap
F. Java.util.Collection
最新试题
Given: foo and bar are public references available to many other threads, foo refers to a Thread and bar is an Object. The thread foo is currently executing bar.wait(). From another thread, what provides the most reliable way to ensure that foo will stop executing wait()?()
Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5?()
Which three changes should be made to adapt this class to be used safely by multiple threads?()
A programmer must create a generic class MinMax and the type parameter of MinMax must implement Comparable. Which implementation of MinMax will compile?()
What is the result?()
Which three will compile and run without exception?()
Which statement is true?()
What is the result?()
What is the result?()
Which statement is true about the set variable on line 12?()