0% found this document useful (0 votes)
22 views13 pages

Unit 1 Question Bank

This document contains a series of multiple-choice questions related to the Abstract Window Toolkit (AWT) in Java. The questions cover various aspects of AWT, including classes, methods, layout managers, and components. It serves as a quiz or study guide for individuals learning about AWT and its functionalities.

Uploaded by

atharvmiraje39
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views13 pages

Unit 1 Question Bank

This document contains a series of multiple-choice questions related to the Abstract Window Toolkit (AWT) in Java. The questions cover various aspects of AWT, including classes, methods, layout managers, and components. It serves as a quiz or study guide for individuals learning about AWT and its functionalities.

Uploaded by

atharvmiraje39
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

UNIT 1 – ABSTRACT WINDOWING TOOLKIT

1. AWT Means?
a) Abstract Windows Toolkit b) Advanced Web Toolkit
c) Abstract Web Toolkit d) Advanced Web Technology

2. Which is the immediate super class of Applet?


a) Container b) Component
c) Frame d) Panel

3. The setSize( ) method is defined by this class…


a) Applet b) Component
c) Frame d) Panel

4. Which class encapsulates a blank window upon which we can draw?


a) Applet b) Canvas
c) Window d) Frame

5. What are the variables defined in ‘Dimension’ class?


a) length and width b) height and length
c) height and width d) len and wid

6. If we want to hide the window, we can use this method…


a) setVisible( ) b) show( )
c) setHidden( ) d) view( )

7. Color class can create object of it using which of the following color values?
a) RGB b) RYB
c) CMY d) HSB

8. The setColor( ) is the method of which class?


a) Applet b) Graphics
c) Color d) Object

9. Which of the following style is not supported by Font class?


a) Font.UNDERLINE b) Font.ITALIC
c) Font.PLAIN d) Font.BOLD

10.All the AWT controls are subclasses of which class?


a) Component b) Container
c) AWTControl d) Window
11.How you can remove all the controls from the applet?
a) Using remove( ) method.
b) Using removeAll( ) method.
c) Using removeAllControls( ) method.
d) It is not possible to remove all controls using single method.

12.Which of the following is passive AWT control?


a) Label b) Button
c) Checkbox d) TextField

13.Which alignment is not supported by Label?


a) Label.RIGHT b) Label.LEFT
c) Label.CENTER d) Label.BASELINE

14.How can we create Radio buttons?


a) Using ButtonGroup class b) Using CheckboxGroup class
c) Using RadioButton class d) Using Button class

15.How to add the names in choice controls?


a) At the time of creation itself. b) Using addName( ) method.
c) Using addItem( ) method. d) Using add( ) method.

16.Multiple selections are allowed in…


a) Menu b) CheckboxGroup
c) List d) Choice

17.How can we copy the ‘List’s contents into ‘Choice’s contents


a) This is not possible.
b) Using copyInto( ) method of List
c) Directly assigning List object to Choice object.
d) Using copyFrom( ) method.

18.What is default block-increment of Scrollbar?


a) 10 b) 5
c) 1 d) We can not use block increment in scrollbars.

19.The immediate super class of TextArea is…


a) TextField b) TextBox
c) TextComponent d) Component

20.Is it possible to change display character of TextField? How?


a) Not possible.
b) Yes, by using setChar( ) method.
c) Yes, by using setEchoChar( ) method.
d) Yes, by using setDisplayChar( ) method.

21.Is it possible to center the text typed in TextField? How?


a) Not possible.
b) Yes, by using setAlignment( ) method.
c) Yes, by using setPosition( ) method.
d) Yes, by putting values in the constructor itself.

22.Which method is used to append the text at the end of TextArea?


a) append( ) b) add( )
c) appendAt( ) d) addAt( )

23.FlowLayout does not support this value of alignment…


a) FlowLayout.LEFT b) FlowLayout.CENTER
c) FlowLayout.RIGHT d) FlowLayout.BASELINE

24.The setLayout( ) is the method of which class?


a) Applet b) Layout
c) FlowLayout d) Graphics

25.BorderLayout does not support this value of alignment…


a) BorderLayout.WEST b) BorderLayout.EAST
c) BorderLayout.NORTH d) BorderLayout.MIDDLE

26.The correct constructor of Insets( ) which uses the values is…


a) Insets(int top, int left, int bottom, int right)
b) Insets(int bottom, int right, int top, int left)
c) Insets(int right, int top, int left, int bottom)
d) Insets(Dimesnion d1, Dimension d2)

27. 12. Which is a component in AWT that can contain another components like buttons,
textfields, labels etc.?
A) Window B) Container
C) Panel D) Frame

28.Which class is used to create a pop-up list of items from which the user may choose?
a) List
b) Choice
c) C) Labels
d) D) Checkbox
29. Which is the container that doesn't contain title bar and MenuBars but it can have other
components like button, textfield etc.?
a) Window
b) Frame
c) Panel
d) Container
30.2. Which is a component in AWT that can contain another component like buttons,
textfields, labels etc.?
a) Window
b) Container
c) Panel
d) Frame
31.How many types of controls does AWT supports these controls are subclasses of
component?
a) 7
b) 6
c) 5
d) 8
32. AWT has more powerful components like tables, lists, scroll panes, color chooser, tabbed
pane etc.
a) True
b) False
33.Which method is used to size a graphics object to fit the current size of the window?
a) getSize( )
b) setForeground( )
c) setBackground( )
d) setBounds()

34.Which Component method is used to access a component's immediate Container?


a) getVisible()
b) getImmediate
c) getParent()
d) getContainer
e)
35.Which of the following are does not direct or indirect subclasses of Container?
a) Frame
b) Applet
c) MenuBar
d) FileDialog
36.Which are false about the Container class?
a) The validate( ) method is used to cause a Container to be laid out and redisplayed.
b) The add( ) method is used to add a Component to a Container.
c) The getBorder( ) method returns information about a Container’s insets.
d) The getComponent( ) method is used to access a Component that is contained in a
Container
37.Which method of the container class can be used to add components to a Panel?
a) add ( ).
b) show( )
c) displayPanel( )
d) display( )
38.Name of the class used to represent a GUI application window, which is optionally
resizable and can have a title bar, an icon, and menus.
(a)Window (b)Panel
(c)Dialog (d)Frame
39.Which of these classes can be added to Frame component ?
(a)Menu (b)Button
(c)Window (d)Applet
40.Which of the following statements about GUI components is wrong?
(a)Swing exitssince version 1.2 of the jdk
(b)You cannot place AWT components on Swing containers
(c)AWT stands for Abstract Window Toolkit
(d)the AWT classes are deprecated.
41.Which is a components in AWT that can contain another components like buttons,
textfields, labels etc.?
(a)window (b)container
(c)panel (d)frame

42.Which method can set or change the text in a Label?


a) getText()
b) All the above
c) setText()
d) d. None of the above

43.Which of these events is generated when a button is pressed?


a) WindowEvent
b) ActionEvent
c) ItemEvent
d) KeyEvent

44.The various controls supported by AWT are


a) Label, Buttons
b) Checboxes, Choice, List
c) Scrollbars, TextArea, TextField
d) All of the above

45.A Checkbox is a control that consists of a


a) combination of a small box
b) A label
c) combination of a large box and a label
d) both (a) and (b)

46.______ generates action event when an item is double clicked, generate action events
when an item is selected or deselected.
a) List
b) Checkbox
c) MenuItem
d) TextBox

47.Which are passive controls that do not support any interaction with the user?
a. Choice
b. List
c. Labels
d. Checkbox

48.Which of these classes can be added to any container class, using the add() method
defined in container class.
a) Button
b) Checkbox MenuItem
c) Menu
d) All of the above

49.Which checkbox will be selected in the following code ( Assume with main and added to
a Frame)
Frame myFrame = new Frame("Test");
CheckboxGroup cbg = new CheckboxGroup();
Checkbox cb1 = new Checkbox("First",true,cbg);
Checkbox cb2 = new Checkbox("Second",true,cbg);
Checkbox cb3 = new Checkbox("Third",false,cbg);
cbg.setSelectedCheckbox(cb3);
myFrame.add(cb1);
myFrame.add(cb2);
myFrame.add(cb3);

a) cb1
b) cb2,cb1
c) cb1,cb2,cb3
d) cb3

50.Which one of the following does not extends java.awt.Component


a) CheckBox
b) Canvas
c) CheckboxGroup
d) Label

51.Look at the following code


import java.awt.*;
public class visual extends java.applet.Applet{
static Button b = new Button("TEST");
public void init(){
add(b);
}
public static void main(String args[]){
Frame f = new Frame("Visual");
f.setSize(300,300);
f.add(b);
f.setVisible(true);
}
}
What will happen if above code is run as a standalone application
a) Displays an empty frame
b) Displays a frame with a button covering the entire frame
c) Displays a frame with a button large enough to accomodate its label.

52.Which is the component in AWT that can contain other components like buttons,
textfields, labels etc.?
a) Window
b) Container
c) Panel
d) Frame

53.The most commonly used layout managers are


a) Flow Layout
b) Border Layout
c) Grid Layout
d) Card Layout
e) All of these

54.The general form to set a specific type of layout manager is


a) void setLayout(LayoutManager lm)
b) Void setLayout(LayoutManager lm)
c) void setLayout(layoutManager lm)
d) Void setLayout(Layoutmanager lm)
55.Positions the components into five regions:east, west, north, south, center
a) BorderLayout
b) CardLayout
c) GridLayout
d) FlowLayout

56.Arranges the components as a deck of cards such that only one component is visible at a
time
a) BorderLayout
b) CardLayout
c) GridLayout
d) FlowLayout

57.Arranges the components horizontally


a) BorderLayout
b) CardLayout
c) GridLayout
d) FlowLayout

58.Arranges the componemnts into grid


a) a)BorderLayout
b) b)CardLayout
c) c)GridLayout
d) d)FlowLayout

59.The CardLayout class defines the following constructors


a) CardLayout() // First
Cardlayout(int hor, int ver) //second
b) Cardlayout() // First
CardLayout(int hour, int ver) //second
c) CardLayout() // First
Cardlayout(int hor, int var) //second
d) CardLayout() // First
Cardlayout(int hour, int ver) //second

60.Default layout manager for subclasses of "Window" is


a) CardLayout
b) Border layout
c) gridbag layout
d) frame

61.What is the default layout for Dialogs ?


a) a)FlowLayout
b) b)Border layout
c) c)grid
d) d)card layout

62.What is default layout manager for panels and applets?


a) Flowlayout
b) Gridlayout
c) BorderLayout

a) These four methods commonly used in?


1)public void add(Component c)
2)public void setSize(int width,int height)
3)public void setLayout(LayoutManager m)
4)public void setVisible(boolean)

a) Graphics class
b) Component class
c) Both A & B
d) None of the above

63.Which layout should you use to organize the components of a container in a tabular
form?
a)Card Layout.
b)BorederLayout.
c) Flow Layout.
d) Grid Layout.

64.How do you change the current layout manager for a container?


a) Use the setLayout method.
b) Once created you cannot change the current layout manager of a component.
c) Use the setLayoutManager method.
d) Use the updateLayout method

65.What best describes the apprearance of an applet with the following code?
import java.awt.*;
public class FlowAp extends Frame{
public static void main(String argv[]){
FlowAp fa=new FlowAp();
fa.setSize(400,300);
fa.setVisible(true);
}
FlowAp(){
add(new Button("One"));
add(new Button("Two"));
add(new Button("Three"));
add(new Button("Four"));
}
}
a) A Frame with buttons marked One to Four placed on each edge.
b) A Frame with buutons Makred One to four running from the top to bottom
c) A Frame with one large button marked Four in the Centre
d) An Error at run time indicating you have not set a LayoutManager

66.What most closely matches the appearance when this code runs?
import java.awt.*;
public class CompLay extends Frame{
public static void main(String argv[]){
CompLay cl = new CompLay();
}
CompLay(){
Panel p = new Panel();
p.setBackground(Color.pink);
p.add(new Button("One"));
p.add(new Button("Two"));
p.add(new Button("Three"));
add("South",p);
setLayout(new FlowLayout());
setSize(300,300);
setVisible(true);
}
}
a) The buttons will run from left to right along the bottom of the Frame
b) The buttons will run from left to right along the top of the frame
c) The buttons will not be displayed
d) Only button three will show occupying all of the frame

67.How will the following program lay out its buttons. Select the one correct answer.
import java.awt.*;
public class MyClass {
public static void main(String args[]) {
String[] labels = {"A"};
Window win = new(Frame());
win.set.layout(new BorderLayout());
for(i=0;i<labels.length;i++)
win.add(new Button(labels[i]), "North");
win.pack();
win.setVisible(true);
}
}
a)The button A will appear on the top left corner of the window.
b)The button A will appear on the center of first row.
c)The button A will appear on the top right corner of the window.
d)The button A will appear on the middle row and column, in the center of the
window.
e)The button A will occupy the whole window.
f)The button A will occupy the complete first row of the window.

68.Which is the container that doesn't contain title bar and MenuBars but it can have other
components like button, textfield etc?
a) Window
b) Frame
c) Panel
d) Container

69.Package of drawstring() method is


a) java.applet
b) java.io
c) javax.swing
d) java.awt

70.The default layout manager of applet is __________


a) GridLayout
b) GridBag Layout
c) FlowLayout
d) BorderLayout

71.getSelectedCheckbox() method of which class__________


a) CheckboxGroup
b) Checkbox
c) Choice
d) List

72.To create a multiline editable control _________ class is used.


a) TextField
b) TextArea
c) Choice
d) Button

73.Which constructor creates a TextArea with 10 rows and 20 columns?


a) new TextArea(new Rows(10), new columns(20))
b) new TextArea(20,10)
c) new TextArea(10,20)
d) new TextArea(200)

74.Following is true about List class.


a) It is multiple choice scrolling list
b) Only one item can be selected from the list
c) It can show multiple selected items in the visible window
d) All of these.

75.Which is the immediate super class of Applet?


a) Container
b) Component
c) Frame
d) Panel
76.Which is passive control?
a) Button
b) Label
c) Checkbox
d) List

77.Package of drwaString() method is_____


a) java.applet
b) java.io
c) java.swing
d) java.awt

78.What ‘C’ specifies in MVC architechure?


a) Counting
b) Checking
c) Control
d) Cache

79.A __________ automatically arranges the components added to a container.


a) Layout Manager
b) Checkbox
c) List
d) None of the above

80.The most commonly used layout managers are


a) Flow Layout
b) Border Layout
c) Grid Layout
d) Card Layout
e) All of these
81.The general form to set a specific type of layout manager is
a) void setLayout(LayoutManager lm)
b) Void setLayout(LayoutManager lm)
c) void setLayout(layoutManager lm)
d) Void setLayout(Layoutmanager lm)

You might also like