class A {
public int getNumber(int a) {
return a + 1;
}
}
class B extends A {
public int getNumber (int a) {
return a + 2
}
public static void main (String args) {
A a = new B();
System.out.printIn(a.getNumber(0));
}
}
What is the result? ()
A. Compilation succeeds and 1 is printed.
B. Compilation succeeds and 2 is printed.
C. An error at line 8 causes compilation to fail.
D. An error at line 13 causes compilation to fail.
E. An error at line 14 causes compilation to fail.
您可能感兴趣的试卷
你可能感兴趣的试题
import java.awt.*;
public class Test extends Frame {
public Test() {
add(new Label(“Hello”) );
add(new TextField(“Hello”) );
add(new Button(“Hello”) );
pack();
show();
}
public static void main(String args) {
new Test ();
}
}
What is the result? ()
A. The code will not compile.
B. A Window will appear containing only a Button.
C. An IllegalArgumentException is thrown at line 6.
D. A Window button will appear but will not contain the Label, TextField, or Button.
E. A Window will appear containing a Label at the top, a TextField below the Label, and a Button below the TextField.
F. A Window will appear containing a Label on the left, a TextField to the right of the Label, and a button to the right of the TextField.
A. Public class getClass()
B. Public Object getSource()
C. Public Component getSource()
D. Public Component getTarget()
E. Public Component getComponent()
F. Public Component getTargetComponent()
A. A flow layout can be used to position a component that should resize horizontally when the container is resized.
B. A grid layout can be used to position a component tat should maintain a constant size even when the container is resized.
C. A border layout can be used to position component that should maintain a constant size even when the container is resized.
D. The grid bag layout can be used to give a grid-like layout which differs from the normal grid in that individual rows and columns can have unique sizes.
E. If two components are placed in the same column of a grid bag layout, and one component resizes horizontally, then the other component must resize horizontally.
A. Int foo = (int) Math.max(bar);
B. Int foo = (int) Math.min(bar);
C. Int foo = (int) Math.abs(bar);
D. Int foo = (int) Math.ceil(bar);
E. Int foo = (int) Math.floor(bar);
F. Int foo = (int) Math.round(bar);
A. Run();
B. Start();
C. Execute();
D. Run(Runnable r);
E. Start(Runnable r);
F. Execute(Thread t);
public class SyncTest{
public static void main(String args) {
final StringBuffer s1= new StringBuffer();
final StringBuffer s2= new StringBuffer();
new Thread () {
public void run() {
synchronized(s1) {
s2.append(“A”);
synchronized(s2) {
s2.append(“B”);
System.out.print(s1);
System.out.print(s2);
}
}
}
}.start();
new Thread() {
public void run() {
synchronized(s2) {
s2.append(“C”);
synchronized(s1) {
s1.append(“D”);
System.out.print(s2);
System.out.print(s1);
}
}
}
}.start();
}
}
Which two statements are true? ()
A. The program prints “ABBCAD”
B. The program prints “CDDACB”
C. The program prints “ADCBADBC”
D. The output is a non-deterministic point because of a possible deadlock condition.
E. The output is dependent on the threading model of the system the program is running on.
A. Existing from a synchronized block.
B. Calling the wait method on an object.
C. Calling notify method on an object.
D. Calling read method on an InputStream object.
E. Calling the SetPriority method on a Thread object.
public class X implements Runnable (
private int x;
private int y;
public static void main(String args) (
X that = new X();
(new Thread(that)) . start( );
(new Thread(that)) . start( );
)
public synchronized void run( ) (
for (;;) (
x++;
y++;
System.out.printIn(“x = “ + x + “, y = “ + y);
)
)
)
What is the result?()
A. An error at line 11 causes compilation to fail.
B. Errors at lines 7 and 8 cause compilation to fail.
C. 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”)
D. The program prints pairs of values for x and y that are always the same on the same line (forexample, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by “x=1, y=1”)
E. 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=2s, y=2”)
1. class A implements runable (
2. int i;
3. public void run () (
4. try (
5. thread.sleep(5000);
6. i= 10;
7. ) catch(InterruptedException e) {}
8. )
9. )
10.
11. public class Test {
12. public static void main (string args) (
13. try (
14. A a = new A ();
15. Thread t = new Thread (a);
16. t.start();
17.
18. int j= a.i;
19.
20. ) catch (Exception e) {}
21. )
22. )
Which statement al line 17 will ensure that j=10 at line 19?()
A. a.wait();
B. t.wait();
C. t.join();
D. t.yield();
E. t.notify();
F. a.notify();
G. t.interrupt();
最新试题
Which statement is true?()
What is the result?()
Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5?()
What is the result?()
What is the result?()
A programmer iterates over the TreeSet and prints the name of each Drink object. What is the result?()
Given that Triangle implements Runnable, and:Which two statements, inserted independently at both lines 35 and 41, tend to allow both threads to temporarily pause and allow the other thread to execute?()
Which three changes should be made to adapt this class to be used safely by multiple threads?()
What is the result?()
What is the result?()