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

Ajpr (QB) 1

The document discusses Java AWT concepts like controls, events, layout managers and event handling. It contains multiple choice questions about controls, events, layouts and event handling in AWT. It tests the reader's knowledge of core AWT concepts through different types of questions.

Uploaded by

dagadeparamdeep
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)
38 views

Ajpr (QB) 1

The document discusses Java AWT concepts like controls, events, layout managers and event handling. It contains multiple choice questions about controls, events, layouts and event handling in AWT. It tests the reader's knowledge of core AWT concepts through different types of questions.

Uploaded by

dagadeparamdeep
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/ 9

1. Which of the following class is derived from the container class?

a) Component b) Panel
c) Menucomponent d) List
2. What are the controls or componenets?
a) Controls or componenets allow users to interact with application.
b) Controls or componenets do not allow users to interact with users.
c) Controls or componenets allow users to interact with users.
d) Controls or componenets allow application to interact with users

3. Which of these methods can be used to know which key is pressed?


a) getModifier () b) getActionKey ()
c) getActionEvent () d) getKey ()

4. Which of the following methods can be used to remove java.awt Component


Object from display?
a) hide () b) disappear ()
c) remove () d) delete ()

5. Which of these methods can be used to determine the type of event?


a) getID () b) getSource()
c) getEvent() d) getEventObject()

6. What does AWT stands for?


a) All writing tools b) Abstract window toolkit
c) Abstract writing toolkit d) All windows tools

7. What is an event in delegation event model used by java programming language?


a) An event is an object that describes a state change in source.
b) An event is an object that describes a state change in processing.
c) An event is a class used for defining object,to create events.
d) An event is an object that describes a state change in object
8. Jar Stands for -----------
a) Java archived b) java array
c) java architecture d) None of the above

9. The various control supported by AWT are :


a) Labels push buttons
b) Checkboxes, choice list
c) Scroll bar, text fields, text area
d) All of these

10. -------------- method is used to register keyboard event listener


a) KeyListener () b) addKListener ()
c) addKeyListener() d) EventKeyboardListener()

11. -----------method is used to register a mouse motion listener.


a) addMouse() b)addMouseListner()
c) addMouseMotionListener() d)EventMouseMotionListener()
12. If Scroll bar is manipulated ------event will be notified.
a) ActionEvent b) ComponentEvent
c) AdjustmentEvent d) WindowEvent

13. Which of these event is generated when a button is pressed ?


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

14. -------- method can be used to determine the type of adjustment event .
a) getType() b) getEventType()
c) getAdjustmentType() d) getEventObjectType()

15. -----------event is generated when computergains or losses input focus.


a) ComponentEvent b) ContainerEvent
c) FocusEvent d) InputEvent

16. Which of the packages contains all of the event handling interfaces ?
a)java.lang b)java.awt
c)java.awt.event d)java.event

17. ------------interfaces define a method itemStateChanged().


a)Component Listener b)ContainerListener
C)ActionListener d)ItemListener

.Which method executes only once


[A] start() method
[B] init() method
[C] stop() method
[D] destroy() method

.Give the abbreviation of AWT?


[A] Applet Windowing Toolkit
[B] Abstract Windowing Toolkit
[C] Absolute Windowing Toolkit
[D] None of the above

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

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

.The following specifies the advantages of It is lightweight. It supports pluggable look and
feel. It follows MVC (Model View Controller) architecture.
[A] Swing
[B] AWT
[C] Both A & B
[D] None of the above

.Swing is not a part of JFC (Java Foundation Classes) that is used to create GUI application?
[A] True
[B] False
41.Which class provides many methods for graphics programming?
[A] java.awt
[B] java.Graphics
[C] java.awt.Graphics
[D] None of the above

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
.The Following steps are required to perform 1) Implement the Listener interface and
overrides its methods 2) Register the component with the Listener
[A] Exception Handling
[B] String Handling
[C] Event Handling
[D] None of the above

How do you indicate where a component will be positioned using Flowlayout?

Pass a X/Y
North, Assign a percentage Do nothing, the
South,East,West. row/column FlowLayout will
parameter to the
grid add method. position the
reference component.

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


a) new TextArea(10, 20)
b) new TextArea(20, 10)
c) new TextArea(new Rows(10), new columns(20))
d) new TextArea(200)
Which of the following creates a List with 5 visible items and multiple selection enabled?
a) new List(5, true)
b) new List(true, 5)
c) new List(5, false)
d) new List(false,5)

A Frame’s background color is set to Color.Yellow, and a Button’s background color is to


Color.Blue. Suppose the Button is added to a Panel, which is added to the Frame. What
background color will be used with the Panel?
a) Colr.Yellow
b) Color.Blue
c) Color.Green
d) Color.White

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


a) new TextArea(10, 20)
b) new TextArea(20, 10)
c) new TextArea(new Rows(10), new columns(20))
d) new TextArea(200)
Ans: a [Usage is TextArea(rows, columns)]

Which of the following creates a List with 5 visible items and multiple selection
enabled?
a) new List(5, true)
b) new List(true, 5)
c) new List(5, false)
d) new List(false,5)

Which layout should you use to organize the components of a container in a


tabular form?
a) CardLayout
b) BorederLayout
c) FlowLayout
d) GridLayout

53) An Applet has its Layout Manager set to the default of FlowLayout. What code
would be the correct to change to another Layout Manager?
a) setLayoutManager(new GridLayout());
b) setLayout(new GridLayout(2,2));
c) setGridLayout(2,2,))
d setBorderLayout();

Which of the following architecture does the Swing framework use?

A. MVC
B. MVP
C. Layered architecture
D. Master-Slave architecture
Which language is used in the swing framework?

A. JavaScript
B. Java
C. React
D. Python

To manage events, Java employs the ____?

A. Custom-based Event Model


B. Retired Event Model
C. Delegation Event Model
D. Object base Model

Swing framework is ____ component?

A. Heavyweight
B. Lightweight
C. Mediumweight
D. smallweight

A ____ is a type of object that organizes components in a container.

A. Event adapter
B. Event Handler
C. layout manager
D. Grid Manager

Which of these events will be generated if we close ActionEvent ComponentE Adjustment WindowEvent
an applet’s window? vent Event
Which of these events is generated when the size of
ComponentEv ContainerEve FocusEvent InputEvent
a component is changed?
ent nt
Which of these events is generated when the
ComponentEv ContainerEve FocusEvent InputEvent
component is added or removed?
ent nt

Complete the following code


public class Buttonl extends Applet implements
{ Button button=new Button("change
the color"); boolean flag=true;
public void init()
{ add(button);
button.addActionListen
er(this); .
}
public void paint(Graphics g)
{ if(flag)
3 setBackground(Color. ActionListener ItemListener MouseListe
7 yellow); else ner
setBackground(Color.red);
}
public void actionPerformed(ActionEvent e)
{ String
str=e.getActionComman
d(); if(str.equals("change
the color"))
{ flag = !flag;
//toggle the flag values on every
click of button repaint();
}
}}

Which componenets are needs to get below shown output..

}
(a) RadioButtons.
(b) Checkbox and CheckboxGroup.
(c) CheckboxGroup.
(d) CheckBoxGroup.

21.select the missing statement in given code.

import java.awt.*;
import java.applet.*; /*
<applet code="MouseEvents" width=300 height=100>
</applet>
*/

public class MouseEvents extends Applet


implements MouseListener, MouseMotionListener
{
String msg = "";
int mouseX = 0, mouseY = 0;
public void init(){
}
//Handle mouse clicked
public void mouseClicked(MouseEvent me)
{
mouseX = 0;
mouseY = 10;
msg = "Mouse clicked";
repaint();
}
public void mouseEntered(MouseEvent me)
{

mouseX = 0;
mouseY=10;
msg = "Mouse entered.";
repaint();
}
public void mouseExited(MouseEvent me)
{
mouseX = 0;
mouseY = 10;
msg = "Mouse exited.";
repaint ();
}

(a) addMouseListener(this);
(b) addMouseListener(this);
addMouseMotionListener(this);
import java.awt.event.*;

(c)addMouseListener();
(d) All of above..

22.Find the missing statement in given code

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="SimpleKey" width=300 height=100>
</applet>
*/
public class SimpleKey extends Applet
implements KeyListener
{
String msg = "";
int X = 10, Y = 20; // output coordinates
public void init()
{
addKeyListener(this);
requestFocus(); // request input focus
}
public void keyPressed(KeyEvent ke)
{
showStatus("Key Down");
}
public void keyReleased(KeyEvent ke)
{
showStatus("Key Up");
}
public void keyTyped(KeyEvent ke)
{
msg += ke.getKeyChar();
repaint();
}
// Display keystrokes.
public void paint(Graphics g)
{
g.drawString(X, Y)
}

(a) { (b) } (c) { and drawstring parameter(d) ) } and drawstring parameter

23.Event class is defined in which of these libraries?

(a) Java.io (b)java.lang (c)java.net (d)java.util

24.Which of these constant value will change when the button at the end of the
scroll bar was clicked to increase its value?
(a)BLOCK_DECREMENT (b)BLOCK_INCREMENT

(c)UNIT_DECREMENT (d)UNIT_INCREMENT
25.Which of these methods can be used to obtain the coordinates of a mouse?
(a)getPoint() (b)getCoordinates() (c)getMouseXY()
(d)getMouseCoordinates()

You might also like