Given the following code, which code fragments, when inserted at the indicated location, will succeed in making the program display a button spanning the whole window area?()
import java.awt.*;
public class Q1e65 {
public static void main(String args[]) {
Window win = new Frame();
Button but = new Button("button");
// insert code fragment here win.setSize(200, 200);
win.setVisible(true);
}
}
A.win.setLayout(new BorderLayout()); win.add(but);
B.win.setLayout(new GridLayout(1, 1)); win.add(but);
C.win.setLayout(new BorderLayout()); win.add(but, BorderLayout.CENTER);
D.win.add(but);
E.win.setLayout(new FlowLayout()); win.add(but);
您可能感兴趣的试卷
你可能感兴趣的试题
A.The rectangle drawn will have a total width of 5 pixels.
B.The rectangle drawn will have a total height of 6 pixels.
C.The rectangle drawn will have a total width of 10 pixels.
D.The rectangle drawn will have a total height of 11 pixels.
What will be written to the standard output when the following program is run?()
public class Qcb90 {
int a;
int b;
public void f() { a = 0;
b = 0;
int[] c = { 0 };
g(b, c);
System.out.println(a + " " + b + " " + c[0] + " ");
}
public void g(int b, int[] c) {
a = 1; b = 1; c[0] = 1; }
public static void main(String args[]) {
Qcb90 obj = new Qcb90();
obj.f();
}
}
A.0 0 0
B.0 0 1
C.0 1 0
D.1 0 0
E.1 0 1
What will be written to the standard output when the following program is run?()
public class Q8499 {
public static void main(String args[]) {
double d = -2.9;
int i = (int) d;
i *= (int) Math.ceil(d);
i *= (int) Math.abs(d);
System.out.println(i);
}
}
A.12
B.18
C.8
D.9
E.27
A.Set extends Collection.
B.All methods defined in Set are also defined in Collection.
C.List extends Collection.
D.All methods defined in List are also defined in Collection.
E.Map extends Collection.
Which code fragments will succeed in printing the last argument given on the command line to the standard output, and exit gracefully with no output if no arguments are given?()
CODE FRAGMENT a:
public static void main(String args[]) {
if (args.length != 0)
System.out.println(args[args.length-1]);
}
CODE FRAGMENT b:
public static void main(String args[]) {
try { System.out.println(args[args.length]); }
catch (ArrayIndexOutOfBoundsException e) {}
}
CODE FRAGMENT c:
public static void main(String args[]) {
int ix = args.length;
String last = args[ix];
if (ix != 0) System.out.println(last);
}
CODE FRAGMENT d:
public static void main(String args[]) {
int ix = args.length-1;
if (ix > 0) System.out.println(args[ix]);
}
CODE FRAGMENT e:
public static void main(String args[]) {
try { System.out.println(args[args.length-1]);
}catch (NullPointerException e) {}
}
A.Code fragment a.
B.Code fragment b.
C.Code fragment c.
D.Code fragment d.
E.Code fragment e.
A.Objects are deleted when they can no longer be accessed through any reference.
B.The finalize() method will eventually be called on every object.
C.The finalize() method will never be called more than once on an object.
D.An object will not be garbage collected as long as it is possible for an active part of the program to access it through a reference.
E.The garbage collector will use a mark and sweep algorithm.
A.The value of an int is undetermined.
B.The value of all numeric types is zero.
C.The compiler may issue an error if the variable is used before it is initialized.
D.The value of a String variable is "" (empty string).
E.The value of all object variables is null.
Which statements concerning the relationships between the following classes are true?()
class Foo { int num;
Baz comp = new Baz();
}
class Bar { boolean flag;
}
class Baz extends Foo {
Bar thing = new Bar();
double limit;
}
A.A Bar is a Baz.
B.A Foo has a Bar.
C.A Baz is a Foo.
D.A Foo is a Baz.
E.A Baz has a Bar.
A.The operation col1.retainAll(col2) will not modify the col1 object.
B.The operation col1.removeAll(col2) will not modify the col2 object.
C.The operation col1.addAll(col2) will return a new collection object, containing elements from both col1 and col2.
D.The operation col1.containsAll(Col2) will not modify the col1 object.
最新试题
What is the output if the main() method is run?()
Which statement is true?()
What is the result?()
Which three will compile and run without exception?()
Which statement is true about the set variable on line 12?()
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()?()
Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo() method, which two statements are true?()
Which statement is true?()
What is the result?()
Which two are possible results?()