UNIT I Test
UNIT I Test
Q. 2 Which is the container that contain title bar and can have MenuBars. It can have other
components like button, textfield etc.?
(a) Panel (b) Frame
(c) Window (d) Container
Q. 3 Which is a component in AWT that can contain another components like buttons,
textfields, labels etc.?
(a) Window (b)
Container (c) Panel (d)
Frame
Page 1 of 58
Q. 5 Which class provides many methods for graphics programming?
(a) java.awt
(b) java.Graphics
(c) java.awt.Graphics
(d) None of the above
Q. 6 These two ways are used to create a Frame By creating the object of Frame class
(association) By extending Frame class (inheritance)
(a) True
(b) False
Q. 7 Which is the container that doesn't contain titlebar and MenuBars. It can have other
components like button, textfield etc?
(a) Window
(b) Frame
(c) Panel
(d) Container
Q. 8 How many types of controls does AWT supports these controls are subclasses of component?
(a) 7
(b) 6
(c) 5
(d) 8
Q. 9 Which are passive controls that do not support any interaction with the user?
(a) Choice
(b) List
(c) Labels
(d) Checkbox
Q. 11 Which class is used to create a pop‐up list of items from which the user may choose?
(a) List
(b) Choice
(c) Labels
(d) Checkbox
Page 2 of 58
Q. 12 Which object can be constructed to show any number of choices in the visible window?
(a) Labels
(b) Choice
(c) List
(d) Checkbox
Q. 13 Which is used to store data and partial results, as well as to perform dynamic linking,
return values for methods, and dispatch exceptions?
(a) Window
(b) Panel
(c) Frame
(d) Container
Q. 14 The following way is used to create a frame is by creating the object of Frame class?
(a) inheritance
(b) association
(c) Both A & B
(d) None of the above
Q. 15 AWT more powerful components like tables, lists, scroll panes, color chooser, tabbed pane etc.?
(a) True
(b) False
Q. 17 In Graphics class which method is used to draws a rectangle with the specified width and height?
(a) public void drawRect(int x, int y, int width, int height)
(b) public abstract void fillRect(int x, int y, int width, int height)
(c) public abstract void drawLine(int x1, int y1, int x2, int y2)
(d) public abstract void drawOval(int x, int y, int width, int height)
Q. 18 Implement the Listener interface and overrides its methods is required to perform in event
handling?
(a) True
(b) False
Page 3 of 58
Q. 19 Public class MenuBar extends .
(a) MenuComponent
(b) MenuContainer
(c) ComponentMenu
(d) MenuBar
Q. 20. Which of the following is true about AWT and Swing components?
(a) AWT components creates a process where as swing components creates a thread
(b) AWT components creates a thread whereas swing components creates a process
(c) Both AWT and Swing components creates a process
(d) Both AWT and swing components creates a thread
Q. 21 Panel is defined as .
(a) The Panel class is a concrete subclass of Container.
(b) A Panel is a window that does not contain titlebar, menubar and border.
(c) Panel is a superclass of Applet.
(d) All of the above.
Page 4 of 58
Q. 26 Which is the correct constructor of GridLayout.
(a) GridLayout(int a)
(b) GridLayout(int num_rows, int num_columns)
(c) GridLayout(int rows, int cols, int vert)
(d) GridLayout(int hor)
Q. 29 Which class is used to represent a single line textbox with password character facility?
(a) TextField
(b) TextArea
(c) Label
(d) Checkbox
Q. 31 Suppose a Panel is added to a Frame and a Button is added to the Panel. If the
Frame’s font is set to 12 point Times New Roman, the panel’s font is set 10 points
Times New Roman and the Button’s font is not set. What font will be used to display the
Button’s label?
(a) 12 point Times New Roman
(b) 11 point Times New Roman
(c) 10 point Times New Roman
(d) 9 point Times New Roman
Page 5 of 58
(d) Both A & B.
Q. 34 positions are the components into 5 regions east, west, south, north, center.
(a) CardLayout
(b) BorderLayout
(c) GridLayout
(d) FlowLayout
Q. 35 What is API?
(a) Application Programming Interchange
(b) Application Programming Interaction
(c) Application Programming Interface
(d) None of these
Q. 36 Panel is defined as .
(a) Panel class is a concrete sub‐class of container
(b) A Panel is a window that does not contain a title bar, menu bar or border
(c) Panel is the superclass of Applet
(d) All of above
Q. 38 When there is a switching condition like ON or OFF, which control is used of following?
(a) Button
(b) RadioButton
(c) ToggleButton
(d) TextField
Page 6 of 58
Q. 40 The getContentPane( ) method is of which class?
(a) JApplet
(b) JFrame
(c) JButton
(d) None of these
Q. 43 Which Text Component method is used to set a TextComponent to the read‐only state?
(a) Editable
(b) NonEditable
(c) setEchoChar
(d) setEditable
Q. 44 How would you set the color of graphics context called g to cyan?
(a) g.setColor(“cyan”);
(b) g.setCurrentColor(cyan);
(c) g.setColor(“Color.cyan”);
(d) g.setColor(Color.cyan);
Q. 46 The setBackground() method is part of which of the following class java.awt package?
(a) Component
(b) Applet
(c) Object
(d) Graphics
Page 7 of 58
Q. 47 What does the following line of code do? TextField tf = new TextField(10);
(a) will set 10 to TextField as its initial text.
(b) Will set the character capacity to 10
(c) Both A & B
(d) None of These
Page 8 of 58
Q. 54 Which of the following does not have its default layout as BorderLayout.
(a) Frame
(b) Dialog
(c) JApplet
(d) All of Above
Page 9 of 58
Q. 61 Which of these Components cannot be added to Frame?
(a) Label
(b) Button
(c) CheckboxGroup
(d) All of above
Q. 63 Which of these classes can be added to any Container class, using the add
method defined in Container class?
(a) Button
(b) CheckboxMenuItem
(c) Menu
(d) MenuBar
Page 10 of 58
Q. 67 The default layout of Applet is .
(a) GridLayout
(b) CardLayout
(c) FlowLayout
(d) BorderLayout
Q. 70. Which of the following is a valid HTML file to run an applet program store in
MyApplet.java file?
a) <APPLET CODE = "MyApplet.class"></APPLET>
b) <APPLET CODE="MyApplet.java" WIDTH=250 HEIGHT=200>
c) <applet code="MyApplet.class" width=250 height=200></applet>
d) <applet code="MyApplet" height =”250” width =”200”></applet>
Q. 71. Which of the following sets the frame, say frame to 300 pixels wide by 200 high?
a) frame.setSize( 300, 200 );
b) frame.setSize( 300, 200 );
c) frame.paint( 300, 200
);
d)frame.setVisible(
300, 200 );
Page 11 of 58
Q. 72. Fill in the blanks so that this program displays a Frame:
import
java.awt.*;
public class
microGUI
{
public static void main ( String[] args )
{
Frame frm = new ( ); frm. ( 150, 100 );
frm. ( true );
}
}
a) Form, setVisible, setOn
b) Frame, setSize, setVisible
c) Frame, setVisible, setSize
d) Window, setSize, paint
Answer: b.
Q. 73. What is the length of the application box made by this program?
import
java.awt.*
; import
java.applet.
*;
public class myapplet
extends Applet { public
void paint(Graphics g) {
g.drawString("A Simple Applet", 20, 20);
}
}
a) 20
b) 5
0
c
)
1
0
0
d)System Dependent
Page 12 of 58
Q. 74.Which components are used in the following output?
Page 13 of 58