0% found this document useful (0 votes)
32 views

UNIT 01 – Abstract Windowing Toolkit (AWT)

Gta

Uploaded by

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

UNIT 01 – Abstract Windowing Toolkit (AWT)

Gta

Uploaded by

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

UNIT 01 – Abstract Windowing Toolkit (AWT)

Q. 1. Give the abbreviation of AWT ?


(a) Applet Windowing Toolkit
(b) Abstract Windowing Toolkit
(c) Absolute Windowing Toolkit
(d) None of the above
Answer: b
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
Answer: b
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
Answer:b
Q. 4 AWT is used for GUI programming in java?
(a) True
(b) False
Answer:a

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
Answer:c
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
Answer:a
Q. 7 Which is the container that doesn't contain titlebar and MenuBars. It can have other
components like Bbutton, textfield etc?
(a) Window
(b) Frame
(c) Panel
(d) Container
Answer:c
Q. 8 How many types of controls does AWT supports these controls are subclasses of
component?
(a) 7
(b) 6
(c) 5
(d) 8
Answer:a
Q. 9 Which are passive controls that do not support any interaction with the user?
(a) Choice
(b) List
(c) Labels
(d) Checkbox
Answer:c

Q. 10 By which method You can set or change the text in a Label ?


(a) setText()
(b) getText()
(c) Both A & B
(d) None of the above
Answer:a

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
Answer:b

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
Answer:c
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
Answer:c

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
Answer: c
Q. 15 AWT more powerful components like tables, lists, scroll panes, color chooser, tabbed
pane etc.?
(a) True
(b) False
Answer: a

Q. 16 These four methods commonly used in?


(i) public void add(Component c)
(ii) public void setSize(int width,int height)
(iii) public void setLayout(LayoutManager m)
(iv) public void setVisible(boolean)

(a) Graphics class


(b) Component class
(c) Both A & B
(d) None of the above
Answer: b

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)
Answer: b

Q. 18 Implement the Listener interface and overrides its methods is required to perform in event
handling?
(a) True
(b) False
Answer: a

Q. 19 Public class MenuBar extends .


(a) MenuComponent
(b) MenuContainer
(c) ComponentMenu
(d) MenuBar
Answer: a

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
Answer: c
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.
Answer: d

Q. 22. What is API?


(a) Application Programming Interchange
(b) Application Programming Interaction
(c) Application Programming Interface
(d) None of these
Answer: c

Q. 23.What is default layout for Dialog?


(a) FlowLayout
(b) GridLayout
(c) CardLayout
(d) BorderLayout
Answer: a

Q. 24 Which method is used to count the number of items is the List.


(a) getItem( )
(b) getSelectedItem( )
(c) getItemCount( )
(d) getCount( )
Answer: c

Q. 25 The correct hierarchy for Panel is


(a) Component – Container – Window – Panel
(b) Component – Container – Applet – Panel
(c) Component – Container – Panel
(d) Container – Component – Panel
Answer: c

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)
Answer: b

Q. 27 What are the types of DialogBox?


(a) Modal DialogBox
(b) Modal and Modeless DialogBox
(c) Modam
(d) None of the above
Answer: b

Q. 28 In the give constructor what third parameter indicates :


ScrollBar s = new ScrollBar(0,10,20,0,1000);
(a) size of thumb
(b) minimum value
(c) Increment value
(d) Initial Value
Answer: a

Q. 29 Which class is used to represent a single line textbox with password character facility?
(a) TextField
(b) TextArea
(c) Label
(d) Checkbox
Answer: a
Q. 30 To set the title to the Frame window method is used.
(a) void setTitle(String str)
(b) void setText(String str)
(c) void settitle(String str)
(d) None of the above
Answer: a
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
Answer: c

Q. 32 Which of the following is true about FlowLayout?


(a) FlowLayout can use multiple rows if the horizontal space in the container is too small to
hold the component.
(b) FlowLayout is the default layout manager of panel and applet.
(c) It is the default layout manager for window.
(d) Both A & B.
Answer: d

Q. 33 Which of the method can be used to output a String in an Applet?


(a) display( )
(b) print( )
(c) drawString( )
(d) transient( )
Answer: c

Q. 34 positions are the components into 5 regions east, west, south, north, center.
(a) CardLayout
(b) BorderLayout
(c) GridLayout
(d) FlowLayout
Answer: b

Q. 35 What is API?
(a) Application Programming Interchange
(b) Application Programming Interaction
(c) Application Programming Interface
(d) None of these
Answer: c

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
Answer: d
Q. 37 Which component of AWT provides compact, multichoice, scrolling component?
(a) List
(b) Choice
(c) Panel
(d) TextArea
Answer: a

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
Answer: c

Q. 39 Which method is used to set password characterfor a TextField?


(a) setPasswordCharacter( )
(b) setEchoChar( )
(c) setPassChar( )
(d) setEchoCharacter( )
Answer: b

Q. 40 The getContentPane( ) method is of which class?


(a) JApplet
(b) JFrame
(c) JButton
(d) None of these
Answer: d

Q. 41 Which class defines setSize( ) method?


(a) Frame
(b) Applet
(c) Component
(d) Panel
Answer: c

Q. 42 is a swing class that allows to enter a single line of text.


(a) TextField
(b) JTextField
(c) EditTextField
(d) TextArea
Answer: b

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
Answer:d
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);
Answer: d
Q. 45 What is use of second parameter in given constructor Lable(String,int)
(a) specifies height of label
(b) specifies width of label in terms of pixel
(c) specifies the alignment of text in label in terms of pixel
(d) specifies width of label
Answer: c
Q. 46 The setBackground() method is part of which of the following class java.awt package?
(a) Component
(b) Applet
(c) Object
(d) Graphics
Answer: a

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
Answer: b
Q. 48 Frame is a standard window, which is of Window class from AWT hierarchy?
(a) Derived class / Subclass
(b) Base class / Super class
(c) Root class
(d) Family class
Answer: a
Q. 49 A is a passive AWT control that do not generate any event?
(a) Button
(b) RadioButton
(c) Choice
(d) Label
Answer: d
Q. 50 The default layout manager of Frame is .
(a) FlowLayout
(b) BorderLayout
(c) GridLayout
(d) CardLayout
Answer: c
Q. 51 Which method is used to check the status of checkbox?
(a) getStatus( )
(b) getState( )
(c) isChecked( )
(d) getChecked( )
Answer: b
Q. 52 Which of the following method is used to set a TextComponent to read‐only mode?
(a) Editable( )
(b) nonEditable( )
(c) setEchoChar( )
(d) setEditable( )
Answer: d

Q. 53 generates action events when an item is double‐clicked.


(a) List
(b) Checkbox
(c) MenuItem
(d) TextField
Answer: c

Q. 54 Which of the following does not have its default layout as BorderLayout.
(a) Frame
(b) Dialog
(c) JApplet
(d) All of Above
Answer: d
Q. 55 Which of the following statement about GUI component is wrong?
(a) swing exists since the version 1.2 of the JDK
(b) AWT stands for Abstract Window Toolkit
(c) You cannot place AWT component on swing container.
(d) The AWT classes are deprecated.
Answer: c
Q. 56 Which of the following package is used for Graphical User Interface?
(a) java.applet
(b) java.awt
(c) java.awt.image
(d) java.io
Answer: b
Q. 57 What are the variables defined in Dimension?
(a) length and width
(b) height and length
(c) height and width
(d) None of these
Answer: c
Q. 58 Which AWT component is not editable?
(a) Button
(b) TextField
(c) FlowLayout
(d) Label
Answer: b
Q. 59 Current text of Label can be obtained using .
(a) setAlignment( )
(b) getAlignment( )
(c) getText( )
(d) setText( )
Answer: c

Q. 60 The method places a Menu m into the MenuBar mb.


(a) mb.addMenuItem(m)
(b) mb.addItem(m)
(c) mb.add(m)
(d) None of these
Answer: c

Q. 61 Which of these Components cannot be added to Frame?


(a) Label
(b) Button
(c) CheckboxGroup
(d) All of above
Answer: c
Q. 62 What is use of second parameter given in Label constructor : Label(String, int)
(a) Specifies height of label in terms of pixels.
(b) specifies width of label in terms of pixels.
(c) specifies the alignment of text in label in terms of pixels.
(d) Specifies maximum numbers of characters in label.
Answer: c
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
Answer: a
Q. 64 What is the use of setEchoChar( ) method?
(a) to set echo in symbol form
(b) to set char in symbol form
(c) Both A & B
(d) to create password in symbol form
Answer: c
Q. 65 method returns currently selected item in choice.
(a) getSelectedItem( )
(b) getSelectedElement( )
(c) getSelectedIndex( )
(d) getItem( )
Answer: a
Q. 66 Which statement with respect to inner class is true.
A. It is a way of logically grouping classes that are only used in one place.
B. It increases encapsulation.
C. It can lead to more readable and maintainable code.
(a) Only A statement is true.
(b) Only B statement is true.
(c) Only C statement is true.
(d) All A,B and C are true.
Answer: d

Q. 67 The default layout of Applet is .


(a) GridLayout
(b) CardLayout
(c) FlowLayout
(d) BorderLayout
Answer: c
Q. 68 Java Applets are used to create applications.
(a) Graphical
(b) user interactive
(c) Both A & B
(d) None of these
Answer: c
Q. 69 The following example shows the creation of applet
Import java.applet.*;
Import java.awt.*;
public class Main extends Applet
{
public void paint(Graphics g)
{
g.drawString("Welcome in Java Applet.",40,20);
}
}
a) Banner using Applet
b) Basic Applet
c) Display clock
d) None of the above
Answer: b

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>
Answer: c

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 );
Answer: a

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) 50
c)100
d)System Dependent
Answer: a

Q. 74.Which components are used in the following output?

a) Label, TextField, Button


b) Applet, Label
c) Applet, Button
d) Grid Layout, Label, Button
Answer: A

You might also like