Hi,
Here r few questions that r confusing me, plz help.
9) In regards to exceptions, which of the following are true?
a) An exception can be thrown by a no argument constructor.
b) An exception can only be thrown by a multi argument constructor.
c) Uncaught exceptions should be listed in the throws clause of a class definition.
d) In all cases except exiting the JVM, the finally clause of a try block is executed.
My answer : a c d
10) In classes A, B, and C, which methods have direct access to A.d?
Class A {
protected double d=3.14;
public static void f() {};
public void g() {};
}
Class B {
public void m() {};
}
Class C extends A {
protected static void s() {};
void t() {};
}
a) A.g
b) C.t
c) B.m
d) C.s
My answer : a b c (assuming that classes A B C r within same package)
14) Which of the following statements is true?
a) An interface can contain a nested top-level inner class.
b) An interface can contain a member inner class.
c) A member inner class can implement an interface.
d) A static method can contain a local class.
e) A static method can contain a nested top-level class.
My answer : a c d ( is "option a" wrong? )
17) With respect to User and Daemon threads:
a) Daemon threads can not be destroyed
b) Running User threads prevent a JVM from terminating program
c) Running Daemon threads prevent a
Java VM from terminating program
d) Daemon threads can not be grouped together
e) The JVM can terminate program when only daemon threads are running
My answer : b d e
18) Primitive type wrapper classes:
a) Allow primitive types to behave as reference types
b) Allow operator overloading to be implemented for primitive numeric types
c) Provide
string parsing and conversion methods
d) Provide arithmetic operators such as plus and minus
e) Are provided for all primitive types, including void
My answer : a c e
21) Methods for a Component are:
a) add()
b) setbounds()
c) setVisible()
d) setEnabled()
e) addComponent()
My answer : b d
22) Based upon the code below, what is true about the Frame constructed:
1. public LayoutFrame() {
2. super();
3. Button b = new Button("What is my location?");
4. Panel p1 = new Panel();
5. p1.add(b);
6. add(p1);
7. }
a) The push button is located in the center of the Frame and will expand to all sides.
b) The code does compile successfully because the superclass constructor is called.
c) The size of the push button is just larger than the label.
d) The push button is located in the upper-left hand corner of the Frame.
My answer : c
23) Based upon the code below, what is true about the
Applet constructed?
1. public LayoutApplet ( ) {
2. setLayout(new BorderLayout());
3. setFont(new Font("Serif", Font.PLAIN, 14));
4. add(BorderLayout.NORTH, new Button("North"));
5. add(BorderLayout.SOUTH, new Button("South"));
6. add("East", new Button("East"));
7. add("West", new Button("West"));
8. add(new Button("Center"));
9. }
a) Statement 2 is ignored and the default Layout Manager for an Applet is used.
b) There is a compile error on line 6: you cannot mix the use of Strings and Constants to specify the location of components.
c) There is a compile error on line 8: the location specification via a String or Constant is not provided.
d) Five push buttons are drawn, with the largest push button in the center.
e) The code compiles successfully
My answer : d e
Thanks
Sanjeet