Q1.The
Container methods add( Component comp ) and add( String name, Component comp)
will throw an IllegalArgumentException
if comp is a: a) button
b) list c) window
d) textarea
e) container that contains this container
Q2.Of the following AWT classes, which one(s) are
responsible for implementing the components layout?
a) LayoutManager//interface implementd by all classes b) GridBagLayout
c) ActionListener
d) WindowAdapter e) FlowLayout
Q3.A component that should resize vertically but not
horizontally should
be placed in a:
a) BorderLayout in
the North or South location
b) FlowLayout as the first component c) BorderLayout in the East or West
location d) BorderLayout in the Center location
e) GridLayout
Q4.What type of object is the parameter for all methods
of the
MouseListener interface?//MouseEvent e
Q5.Which of the following statements about event handling
in JDK 1.1 and
later are true?
a)A class can implement multiple listener interfaces b) If a class implements a listener interface,
it only has to overload the methods it uses c) All of the MouseMotionAdapter class methods
have a void return type.
Q6.Which of the following describe the sequence of method
calls that result in a component being redrawn?
a) invoke paint()
directly
b) invoke update which calls paint() c) invoke repaint() which
invokes update(), which in turn invokes paint() d) invoke repaint()
which invokes paint directly
Q7. What is Swing?//swing is top class to all
awt
//swing components are lightweight
Q8) What
are peer "classes"?//displays the AWT components as the operating
system’s graphical capability
Q9. Which of the following are valid constructors for a TextField .
1. TextField();
2. TextField(int rows , int cols);
3. TextField(int cols , String txt);
4. TextField(int cols);
5. TextField(String txt , boolean scrollBars);
Q10. What is the default layout for a Dialog ?
1. FlowLayout
2. GridLayout
3. CardLayout
4. BorderLayout
5. GridBagLayout
Q11. True or false.
A Dialog is a subclass of Frame.
1. True
2. False
12. Which of the following are valid constructors for a MenuItem ?
1. MenuItem()
2. MenuItem(String name)
3. MenuItem(String name , boolean removable)
4. MenuItem(String name , MenuShortcut sc)
5. MenuItem(boolean check)
Q13.Please
select the size of an inttype
A.32 bytes
B.16 bits
C.32 bits
D.16 bytes
Q14.Select
default value of boolean type
a.true
b.false
c.0
d.1
Q15)Can Innerclassaccess a outer class member variable?
public class OuterClass
{
int outerVariable = 100;
class MemberClass
{
int innerVariable = 20;
int getSum(int parameter)
{
return innerVariable +outerVariable + parameter;
}
}
public static void main(String[] args)
{
OuterClass outer = new OuterClass();
MemberClass inner = outer.new MemberClass();
System.out.println(inner.getSum(3));
outer.run();
}
void run()
{
MemberClass localInner = new MemberClass();
System.out.println(localInner.getSum(5));
}
}
Q 16) What
is the advantage of Anonymous Inner class”