please explain, thanks!
1. How does the weighty property of the GridBagConstraints objects used in grid bag layout affect the layout of the components?
A]It affects which grid celll the component ends up in
B]It affects how the extra vertical space is distributed
C] It affects the alignment of each compnent
D] It determines whether components completely fill their allotted dispplay area vertically
2.Which statements concerning the event model of the AWT are true?
A]At most one listener of each type can be registered with a component
B]Mouse motion listeners can be registered on a List interface
C]There exists a class named containerevent in package .event
D]There exists a class called mousemotionevent in package.event
E]There exista a class called ActionAdapter in package.event
3.What will be the appearance of an
applet with the following init() method?
public void init() {
add(new Button("hello"));
}
A]nothing appears in the applet
B]a button will cover the whole area of the applet
C]button will appear in the top left corner of the applet
D]button will appear centred in the top region of the applet
E] button will appear in the center of the applet
3.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):
Ewin.setLayout(new FlowLayout()); win.add(but)
4. What is wrong with the following code?
class MyException extends Exception {}
public class Qb4ab {
public void foo() {
try {
bar();
} finally {
baz();
} catch (MyException e) {}
}
public void bar() throws MyException {
throw new MyException();
}
public void baz() throws RuntimeException {
throw new RuntimeException();
}
}
A]since the method foo does not catch the exceptioon generated by the method baz it must declare the runtime exception in its throws
B]a try block cannot be followed by both a catch and a finally block
C]an empty catch block is not allowed
D]a catch block must be followed by a finally block
E]a finally block must always follow one or more catch block