0% found this document useful (0 votes)
428 views20 pages

Dev-Cpp: A Applet

This document provides a list of files on a local disk drive with names, dates modified, and types. It includes common program and system files like Corel, cygwin, Dell, and Windows files. It also includes some review questions related to Java applets and the Abstract Windowing Toolkit (AWT).

Uploaded by

Suyash Hagir
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)
428 views20 pages

Dev-Cpp: A Applet

This document provides a list of files on a local disk drive with names, dates modified, and types. It includes common program and system files like Corel, cygwin, Dell, and Windows files. It also includes some review questions related to Java applets and the Abstract Windowing Toolkit (AWT).

Uploaded by

Suyash Hagir
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/ 20

Output

Look i Local Disk (C)

Name Date modified Type

Ouck acess
Corel 03-Jul-17 2:33 PM Fide fol
cygwin 09-Jul-16 804 PM File fol
Dell 29-Apr-16 1:50 PM File fol
Dev-Cpp 12-Jul-16 7:57 PMFlefot
esktop ecipse 19-Apr-194:50 PM File fol
ESD 27-Jun-18 1:39 PM File fol
hibematejar 06-Jan-16 3:27 PM File fol
NOarne HP Universal Print Driver 02-Aug-18 12:32 P.. Filefol
HP_UM4345MFP PS 32bt 02-Aug-18 1248 P... File fol
inetpub 25-Jun-18 913 PM Filefol
This PC Intel 13-Sep-15 849 PM File fol
logs 31-Oct-17 1057 AM File fol
MnGW 04-Feb-16,1:27PM Filefol

Fles o ty Al Fles C: ace

Review Questions
1. What is Dialog box?
2. Write a java program to illustrate Filedialog box.

Multiple Choice Questions


Q.1 Give the Abbreviation of AWT
a Applet Windowing Toolkit
vbAbstract Windowing Toolkit
Absolute Windowing Toolkit
a None of these
Q.2 Which is a component in AWT that can contain another components like buttons, textfields, labels
etc.?
a Window Container
Panel d Frame
Q.3 How many types of controls does AWT support?
6
5 d8

T Technical
TM

Publications An up thrust for knowledge


Adoanced Java Programming 32 Abstract Windowing Toolki
Q4 Which class provides many methods for
atAppletviewer Appletscreen
graphics programming? Appletwatcher dAppletshow
ajava.awt bljava.Graphics Q.14 Java applet are used to create

efjava.awt.Graphics d None of these applications.


Q.5 Which is the container that doesn't contain title algraphical buser interactive
bar and MenuBars. It can have other components eboth (a) and (b) d none of the above
likebutton, textfield etc? Q.15 Which of these functions is called to display the
a Window bFrame output of an applet ?
anel d Container a display0 paint)
Q6 Which object can be constructed to show any
displayApplet) dShow)
number of choices inthe visible window? Q.16 Which of these methods is a part of Abstract
a Choice b Menu Window Toolkit (AWT) ?
List d Checkbox a display0 Bpainto
a.7 By which method we can set or change the text cshow) all of the above ..
ina Label in AWT? a.17 Which object can bé constructed to show any
setText) DgerText0 number of choices in the visible window ?

CaddText0 dall of these a Labels bChoice


Q8 On which side applet always executed? cist d Checkbox
a Server side Client side Q.18 Which of the following class is derived from
a9 Which method of the Applet class displays the the container class?
result of applet code on screen ?
a Component Panel
a run) method bpaint) method cMenuComponent d List
c drawstring) method main) method Q.19 When we invoke repaint) for a

Q10 Applet can be embedded in java.awt.Component object, the AWT invokes


aHTML document bword document themethod
gif file d rtf file a draw bupdate()
Q11 Which of the following is true about applet? c show) dpaint)
a Applets do not have main) method Q.20 Which method executes only once ?
b Applets must run under appletviewer or web a starto b]stop0
browser einit) d destroy0
The user I/O is not performed using Java's stream Q.21 What does the following line of code do?
yO class
Textfield text = new Textfield(20);
all of these
a12 Executable applet is. a Creates text object that can hold 20 rows of text.
a applet file bjava html r Creates text object that can hold 20 columns of
Cjava file text.
lass file
c Creates the object text and initializes it with the
Q.13 Which of the following is used to interpret and
value 20.
executeJava Applet Classes Hosted by HTML?
d This is invalid code
Technical Publications-An up thrust for knowledge
Adranced a a Programming
1 33
Abstract Windowing Toolkit.
Q.22 Whic of these classes can be added to any
cScroll bars, text fields, text area
Container dass, using the add method defined in
All of these
Container class? in
Q.31 Which layout manager places components
JaButton bCheckboxMenultemn one of five regions : north, south, east, west, and

Menu dMenuBar center?


a.23 Which of the following methods can be used to
a AbsoluteLayout b GridLayout
change the size of a
java.awt.Component object ? FlowLayout
eBorderLayout
adimension) fsetSize()0 a.32 Arranges the components horizontally
carea) d size0 a BorderLayout b CardLayout
.24 Which of the following methods can be used to
c GridLayout FlowLayout
remove a java.awt.Component object from the
display ? a.33 The most commonly used layout managers are

disappear0 b delete0 a FlowLayout b BorderLayout


cremove) nide0 cGridLayout dAll of these
Q.25 These two ways are used to create a Frame Q.34 Default layout manager for subclasses of

1. By creating the object of Frame class (association) window is

2. By extending Frame class (inheritarnce)


al cardlayout bGridBaglayout
Frame dBorderlLayout
rue DFalse Q.35 Each menu is associated with a list
Q.26 The title of the frame can be set in AWT using
of menuitems:
the method.
a Checkbox bDrop-down
a setHeading 5setTitle Choice d None of these
lCreate Title d Settitle Q.36 Which class can be used to represent a
Q.27 Which are passive controls that do not support checkbox with a textual label that can appear in
any interaction with the user ? a menu ?

a Choice bList a MenuBar bMenultem


Labels dCheckbox cCheckboxMenultem d Menu
Q.28 How mariy ways can we align the label in a Q.37 Which abstract class is the super class of all
container?
menu related classes?
a1 b2 MenuComponent b MenuBar
d4 c Menultem
d CheckboxMenultem
Q.29 By which method we can set or change the text Q.38 Menu items are added to
ina Label in AWT? a menus b menubar
asetText0 b getText0 c frame dboth a and b
addText0 dall of these Q.39 Dialog box does not have minimize and
0 The various controls supported by AWT are: maximize button
alLabels, push buttons true D false
bjCheckboxes, choice list
TM
Technical Publications An up
thrust for knowledge
1-34 0stract WNT
Aduanced Java Programming
the
Q.40 A modeless if
dialog box is referred to as
to continue
user does not have to close it in order

using the application that owns the dialog box


true b false
from
Q.41 The class displays a dialog window
which the user can select a file.

aDialog b PileDialog
c File d None of these

Answere:

1. b3 4
5. |a8.
9. b10. a 11. d 12. d
13. 14.e 15. |b 16. b
17.c 18. b 19. 20. c
21. b 22. a 23. b 24. d
25 a 26.b 27. c 28.
29. a 30. d 31. 32. | d
33. d 34a 35. b 36.
37. a38. a 39. a 40. a
41. b
O00
dvanced Java Programming
2- 25
For the button
component the color, the size of the Swings
button will be decided by the view. Multiple Cholce Questlons
Q.1 Pluggablelook and feel and lightweight
The controller is for
managing user interaction
the components are the features supported by
with the model. It is basically for
input. The controller takes handling the user a Swing b AWT
of mouse
care
keyboard events. For example For the and Core Java djNone of these
button a.2 Swing is based
on architecture
component the reaction of events on the button a client server model view controller
press will be decided by the controller.
The MVC architecture of
c layered d none of these
swing specifies how these Q.3 Swing is not a part of JFCJava Foundation
three Objects (Model, View and
Controller) interact. Classes) that is used to create GUI application
For the text field the model is al True
contents of the text
field. The model
nothing but the
Q.4 The Java Foundation Classes
False
must (JFC)is a set of
implement method to change the contents and
the GUI components which simplify the
to discover the contents. For development of desktop applications.
textexample model
had methods to add, to remove the characters. One aTrue b False
important thing to note is Q.5 Following letter used
that the model is as a prefix to swing
completely non visual. component.
a A
For a single
model there can be more
than one
Ds
views. Each view can show different aspect of the Q.6 is of the features of
content. For example- A particular web page can be one
object oriented
programming that allows the creation of
viewed in its WYSIWwYG (What-You-See-Is-What hierarchical classifications.
You-Get) form or in the raw tagged form. But there a Polymorphism bClass
are some components like button for which it is not eInheritance
ossible to have multiple views for the same model. d Object
a.7 In Swing JButton dass is derived from
The controller handles the user-input events such as a AbstractButton bToggleButton
mouse clickS and keyboard strokes. On receiving cJComponent d None of these
he events the controller decides whether to Q.8 The
JTextComponent derives two components
ranslate it into corresponding model or in views. JTextField and
f user presses the button then the controller calls aComboBox TextArea
he event handling methods in order to handle the cJSlider dAll of the above
utton press. The controller tells the view to Q.9 In Swing class hierarchy the class present at the
update
self and to display the desired result. For root is
isplaying the desired result the view reads the aComponent bWindow
ontent from the model. Thus model-view and cContainer aObject
Q.10 pane can be used to add
ontroller works together in order to accomplish the
Component to container
ertain task.
a Glass bContent
jew Question c Container d All of above
Write a short note on -MVC Architecture Q.11 Select the correct source code
using swing for
generating following output.

TM

Technical Publications An up thrust


for knowledge
2-26
Adranced Jaoa Progra1ming
Applet Viei m
Appet
Applet Viewer: Ap
Applet

WELCOME TO SWING PROORAM

Apole aned.

a two circle, two arcs


b three circle, one arc and one rectangle
f o u r circles

Applet started dthree circles and one arc


Q.13 To represent Icon file in swing label we use
a setimg bsetlcon
C serLabellcon d none of this
public class public class AppletDemo
AppletDemo extends extends JApplet a.14 Which of the following component allows
JApplet multiple selection?

public void
aList JComboBox
public void paint(Graphics g) cJLAbel d All of the above
paint(Graphics g)
g.drawString("WELcOME Q.15
TO SWING
g.msgWELCOME TO PROGRAM,20,40);
sWING
PROGRAM 20,40);

public class public class AppletDemo


AppletDemo extends JApplet

public void public void paint(Graphics


paint(Graphics g) )

To generate above output we need


gdrawstring WELCOME g.display("WELCOME TO al List, choiceButton, Imagelcon
TO sWING swINGPROGRAM",20,40); bComboBox, Image Icon,Label
PROGRAM 20,40); cList and Image Icon
d ComboBox and Image Icone

Q12 The components used to display following


imageare
M
Technicel Publications An up thrust for
knowiedge
adounced Java PrOgramming

2-27 Swings
16
To generate
following output the
thatare used are components
Appiet
Appu Ap
Appleorange Grape Apple Applet Applet
**asBAssIStsssAsdsdstiasioissjojad01
C++ Uava
Lpwnvwnyownunwmwwd.A2i

Python

Checkbox, Textbox
6 Radiobutton, Textbox
C Checkbox,button

a List, Textbox

a17 The subclass of ToggleButton is_


Applet started. Applet started.
JButton b JCheckBox
cJRadioButton a Both b and c
o18 The Swing Component classes that are used in
Encapsulates a mutually exclusive set of Ap
w
buttons?
HOpier Aplet
aAbstractButton ButtonGroup Java Java w******

clJButton d Imagelcon *wwwww wwww www

a19 Select the correct Pyhon


output generated by
following code
import java.awt.";
import java.applet.";
<applet code=Test.class height=200 width- 200>
/applet>/
public class Test extends Applet

public void init()


Applet started
eeoeRWRNR WNW NAwwwwwwwww
Appiet starte d.
List 1= new List(2,true);
ladd('Java") Q,20 Which method of the component class is used
Ladd('C++"): to set the position and size of a component ?
Ladd('Python"); a setPostion setBounds
add();
setSize d none of these
Q,21 Select the correct option

I. Canvas is a component
IL.ScrollPane is a container
aIis True and II is False
bIis False and II is True
cl and II both are False
and II both are true

Technical Publications An up thrust for knowledge


Adranced jare Programming 2- 28
ScrolIPaneConstants.
-
int hecrollbar
a22 The difference between Scrollbar and
HORIZONTAL _SCROLLBAR_AS_NEEDED;
Scrollpane is JScrollPane mypane =
ble, vscrol
new JSCrolIPane(table, var.

Scrolbaris component and Scrollpane is hecrollbar):


container contentPane.add(mypane, BorderlLayout.CENTER
b Sarolibar is container and Scrollpane is
component
Scrollbar and Scrolpane both are components Error in statement in which JTable is created
and not container 6 Eror in statement in which JScrollPane is creat
Error in statement in whichapplettag is decla
dScrolibar and Scrollpane both are container and te
not components d None of these
a23 Frame dass Extends Window. Q.27 JPanel and Applet use
True bFalse their default layout
a24 Which is the container dass? FlowLayout GridLayout
Window bFrame Borderlayout d GridBaglayout
a A l ofthe above a28 Which components are used to generat
Dialog following output ?
a25 Following is uneditable control
Button b Textfield
Label dList
a 2 Debug the following program
import javazswing;
mport javaam'
npo javaasvingzee.;
<appe code=TableDemo width=300 beigat=100>
<lappiet

pubtic cass TabieDemo extends JApplet

pubtic void inie

Conainer oontentPane =getContentPane(:


ootertPanesetiayoutnew Bozderdayout);
final SrrinatIth = {Neme, "City, 'Salary,Designation" };
final Oiecll wytable = {
lafanel, TabbedPane, Radio button
'Aru', Pune, D00Acoountant}. bTabbedPane, List
Aschana, "hmbai, T000 Ezecutive', cTabbedPane,Panel
Shivani', "Pangiore, 10000 Manager. dLabel, TabbedPane, Checkbox
Priyenike, 'Cherna, 00rProgrammer Q.29 MVC stands for
cnike', Hyderabad",*10000.Desigmer),
halpe', Hyderabed, 12000" Directory. a Model Version Control
Anuj, Delh, 17000 Director bModel View Controller
Kuma,Pune, 10000 Manager cMini View Controller
d Major View Controller
Table table = nem JTable(mytable Q.30 MVC architecture is used by swing
izd vwcolbar = ScrolPaneConstants.
True b False
VERTICAL SCPOLLBAR_AS_NEEDED
Tecricel Pubications- An up thrust for knowledge
T
Adancedana PrOgrammig

2-29 Satngs
s w i n g - g i v e s tthe visual
n representation of
a31 the component
21. d a 23. 24. d
22

View
/Model

dNone of these 25.e 26. a 27. a28. a

cController
29. b 30. a 31. b 32. e
n swing
the event1
handling task is carrie out
a.32
by 33. a L
Model
b View
dNone of these Explanations:
eontroller
Q.19: In above code we have pass 2 as a first
represents enterprise data and the business items
a33 parameter to the constructor list. Hence first two
rules that gives access to enterprise data.
of the list will be displayed. The second parameter to
CModel bView S t 1s true that means this list is a scrollable. Hence the

Controller dNone of these correct option is c.

0.21: Canvas is a rectangular area where the


application can draw or trap input events. ScrollPane
Answers:

implements horizontal and vertical scrolling


.a2b3. b4a Q.26: While creating the JTable we need to pass both
5. d6c7 a8. |b table data and header data. The correct statement is
9. d 10.b11. b12. d JTable table = new JTable(mytable,th};

13. b 14.a 15. b16. a


17. d 18.b 19. e 20. b O00
Advanced Java Programming
3- 16
a ComponentListener
Event Hana
Ados
Multiple Cholce Questions: b ContainerListener

.1 Which of these packages contains all the event


cActionlListener

handling interfaces dItemListener


of these methods will be
aljava.lang bjava.awt Q.12 Which
character is entered? nvoked it,
ejava.awt.event d java.event
Q.2 Where can the event handling code be
written ?
akeyPressed() bkeyReleased() a.

a Same class b Other class keyTyped) d keyEntered()


a
cAnonymous class dAll mentioned above Q.13 Which
of these are constants
Q.3 Which of these class is super class of all the WindowEvent class ? ned b

events? a WINDOW_ACTIVATED

al EventObject bEventClass b WINDOW_CLOSED

c ActionEvent d ItemEvent c WINDOW_DEICONIFIED

Q.4 Which package provides many event classes Q.


dAll of the mentioned
and Listener interfaces for event handling ?
a.14 Which of these events is generated by a
a java.awt bjava.awt.Graphics bar?

cjjava.awt.event dNone ofthe above a ActionEvent bKeyEvent Q.


Q.5 Which of these interfaces handles the event cWindowEvent AdjustmentEvent
when a component is added to a container ? a.15 Which of these constant value will cha a

aComponentListener bContainerListener when the button at the end of scroll bar


clicked to increase its value ?
FocusListener dInputListener Q.2
a BLOCK_DECREMENT
Q.6 Which of these interfaces define a method
b BLOCK_INCREMENT
actionPerformed)?
a ComponentListener b ContainerListener cUNIT_DECREMENT
ActionListener d InputListener UNIT_INCREMENT
Q.2
Q.7 Which of these interfaces define four methods ? Q.16 Which of these methods is defined i
pub
MouseMotionAdapter class ?
a ComponentListener b ContainerListener imp
cActionListener d InputListener amouseDragged)
But
Q.8 Which of these events will be generated if we bmousePressed()
bo
close an applet's window? emouseReleased() pub
al ActionEvent bj ComponentEvent dmouseClicked()
eAdjustmentEvent Window Event these
Q.17 Which of methods will respond w ad
bu
a.9 Which of these events is generated when a you click any button by mouse?
button is pressed ? amouseClicked() b mouseEntered() pub
aActionEvent bKeyEvent cmousePressed() All of the mentioned
cWindowEvent dAdjustmentEvent Q.18 Which of these is superclass of all dapt if(
Q10 Which of these methods can be used to obtain classes?
the command name for invoking ActionEvent
Applet b jComponentEvent el
object? cEvent dInputEvent
a getCommand) getActionCommand() Q.19 Which of these methods can be useu
cgetActionEvent0 ldgetActionEventCommand) the coordinates of a mouse ? put
Which of these interfaces define a method
Q.11
itemStateChanged()? getPoint0
cgetMouseXY()
b getCoordinates)
d getMouseCordinates
Technical Publications An up thrust for
knowledge
Event Handling
3-17
MouseEvent is subdlass of which of these
Q20 dasses ? String str=e.getActionCommand():
fstr.equals(change the color"))
ComponentE
ent bj ContainerEvent
c ItemEvent

dInputEvent flag Iflag:


every click of
button
toggle the flag values on

Q21 Which of these are


integer constants repaint():
of
TextEvent class ?
a TENT CHANGEDD

TENT FORMAT_CHANGED 2 ActionListener ItemListener


TENT_VALUE_CHANGED
MouseListener d None of these
TENT SIZE _CHANGEDD Q.26 Which event gets generated when the key is
o22 Which of these methods is used to obtain the typed?
object that generateda WindowEvent? aKEY_PRESSED KEY_TYPED
getMethod) bgetWindowO eKEYRELEASED d None of these
gerWindowEvent) dgetWindowObject) a.27 What method is used to distinguish between
023 Which of these methods is used to get x single, double and triple mouse clicks?
coordinate of the mouse? a getButton) b getPoint)
a getX) b getXCoordinate0 getClickCount) d getXO
getCoordinateXO |dJgetPointX) Q.28 The getNewState) method belongs to.
Q24 Which of these is superclass of WindowEvent a TextEvent Class
class?
bMouseEvent Class
e WindowEvent
ComponentEvent CWindowEvent Class
cItemEvent aInputEvent dKeyEvent Class
0.25 Complete the following code
public class Button1 extends Applet Q.29 For scrollbars _event class is used
mplements a ActionEvent b TextEvent
Button button=new Button('change the color);
leAdjustmentEvent d ContainerEvent
boolean flag=true; Q.30 Which of the
following is the highest class in
public void init() theevent-delegation model?
a java.util.EventListener
add(button); Ejava.util.EventObject
button.addActionl.istener(this);
public void paint(Graphics g)
Gljava.awt.AWTEvent
djava.awt.event.AWTEvent
if ag
setBackground(Color.yellow);
else

setBackground(Color.red):
ublic void
actionPe
Performed(ActionEvent e)

Technical Publications -An up thrust for knoledge


3-18
Advanced Java Programming a l actionPerformed(ActionEvent e)

added as
Q.31 When two itemStateChanged( ItemEvent
itemEvent e)
e)
itemStateChanged
are
or more objects is
which listener
listeners for the same event, action(Event e,Object o)
f first invoked to handle the event
a The first object that was added as listener. d xtValueChanged( TextEvent e):
b The last object that was added as listener.
Answers
will be
cThere is no way to determine which listener 1. c 2 d3. a
invoked first. 5. b 6 . c 7. a 8.
dIt is impossible to have more than one listener tor a
9. a 10.|b 11. d 12
given event.
13. d 14.d 15. d 16.
Q.32 Consider following code and fill up thecor
event listener method 17. d 18. a 19. a 20. a

applet code="checkgroup" width=300 height=250


21. c 22 b23. a 24. b
s/applet 25. a 26.
27. c2a c
public class checkgroup extends Applet implements
29. c 30. |b | 31|c 32
ItemListener
Explanation
String msg=""; Q.5 The ContainerListener defines me
CheckboxGroup gr=new CheckboxGroup(: recognize when a component is added to a
Checkbox boxi=new Checkbox("Candy".gr.true);
Checkbox box2=new Checkbox("lce-cream".gr.false from a container.
Checkbox box3=new Checkbox("Juice".gr,false)
public void init()

add(box1);
add(box2);
add(box3);
box1.additemListener(this);
box2.addItemListener(this);
box3.additemListener(this);

public void

repaint();

public void paint(Graphics g)

msg=I ike";
msg+=g.getSelectedCheckbox().getlabel(0:

g.drawString(mag.10,100);

echnical Puhlicatings
Multiple Cholce Questions ?
Q.1 Which contains the classes and
interfaces required for Java networking
package
ajava.io bjava.util
cjava.net djava.awt
class ?
Q.2 Which methods are commonly used in ServerSocket

a public OutputStream getOutputStream()


bpublic Socket accept)
cpublic synchronized void close)
d none of the above
listen for either local client or remote client programs?
Q.3 Which class is used to create servers that
ServerSockets b httpServer
httpResponse d none of the above
Q.4 Which methods are commonly used in ServerSocket class?
a public OutputStream getOutputStream()
bpublic Socket accept0

c public synchronized void close()


dnone of the above
network?
Which of these is a protocol for breaking and sending packets to an address
across a
Q.5
b DNS
TCP/P
d Proxy server
cSocket
reserved for specific protocols?
Q.6 How many ports of TCP/IP are
a 10 1024
c 2048 512
Q.7 How many
bits are in a single IP address?
b 16
c32 64
Technlcal Publcations An up thrust
for knowledge
4-33
a8 URLstands for Unifcform Resource Networking Basics
a W'eb page. Locator and
represents a reso the World Wide Web, such as

True b False
Which of these class is used to
h of

bURL encapsulate address and DNS?


aDatagramPacket
IP
hetAddress

The DatagramSocke dContentHandler


and
DatagramPacket
Q.10

pagramming. classes are not used for connection-less socket


Tnue

Which of these is
False
a11
a.11 a full form of DNS ?
aData Network Service
Data Name Service
cDomain Network Service
Domain Name Service

a.12 What is the output of this program?


import java.net.;
class networking {
public static void main(Stringll args) throws
InetAddress obj1 = UnknownHostException {
InetAddress obj2 = InetAddress.getByName("www.google.com");
InetAddress.getByName('www.facebook.com");
booleanx = obj1.equals(obj2);

System.out.print(x);

a 0 1
True aFalse
Q.13 The client in socket
programming must know which informations ?
a IP address of server |bPort number
Both a and b
dNone of the above
a14 Datagram is basically an information but there is no guarantee of its content, arrival or arrival tine.
aTrue False
15 What is the output of this program ?
import java.net.";
class networking {
public static void main(Stringll args) throws UnknowwnHostException
InetAddress objl =
InetAddress.getByName(www.google.com")
InetAddress obj2 = InetAddress.getByName(www.google.com'%
boolean x= abj1.equals(obj2);
System.out.print(z);

ao
ue False
Technicel Publicetions An up thrustfor knowedg
Advanced Java Programming 4-34 iruao
a.16 Port number 80 is reserved for a.20 Which method of URI
, protocol
and it has cmplete u h maud
aFTP HTTP URIL in Java ?
a Telnet manipulate
SMTP
a.17 While using the getlLocalHost() method the a java.net.URL
bjava.net.URIconnection
exceptionisthrown
afUnknownHostException bNullHostException java.net.URI
d None of the above
LostHostException diOException
Q.18 The class is used for accessing the Answers
attributes of remote resource.
1 . 2 b 3.4 b
a URLconnection URL 6.
b7
URI dnone of these
9. c19. b 11. d 12.
a.19 The correct way of using ServerSocket is 13. c 14. | a 15.c 16
a ServerSocket{int port)
bServerSocket(int port, int maxQueue) 17. a 18.a 19. d 2
cServerSocket(int port, int maxQueue, InetAddress
localAddress)
aAll of these
PrOgTu

6-17 Interacting with Database


rs.close();

rs=null;
c2
.Which type of driver provides JDBC access via
if(statl=null) one or more ODBC drivers?
{ a Type 1driver bType 2 driver
stat.close();
cType 3driver d Type 4 driver
stat nul;
.8 Which type of driver converts JDBC calls into

if (con I= null) ne network protocol used by the database

management system directly?


con.close); a Type 1driver bType 2 driver
con = null;
Type 3driver Type 4 driver
d
.7 Which type of driver of JDBC is called pure
catch (SQLException e) {} driver?
aType 1driver bType 2 driver
lType 3driver d Type 4 driver
Q.8 Which type of driver of JDBC called
is partly
utiple Choice Questions Java Driver?
stands for_ a Type 1 driver bType 2 driver
at JDBC
ava Database Connectivity cType 3 driver dType 4 driver
Q.9 Which driver is efficient and
bJava Database Control always preferable
for using JDBC
c Java Database Components applications?
a Type 1driver b Type 2 driver
a None of these Type 3 driver
02 Which statements about JDBC are true ?
d Type 4 driver
Q.10 The JDBC-ODBC bridge
a DBC is an API to connect to relational-, object and is
XML data sources.
a three tiered bmultithreaded
cbest for any platform d all of the above
bJDBC stands for Java DataBase connectivity.
Q.11 Which driver is called thin-driver in JDBC?
c JDBC is an API to access relational databases, as

spreadsheets and flat files. aType-4 driver b Type-1 driver


c Type-3 driver d Type-2 driver
jDBC is an API to bridge the object-relational
mismatch between OO Q.12 Which driver type of JDBC is used in either
programs and relational
databases. applet or servlet ?

Which packages contain the JDBC classes ? a Type 1and 2 b Type 1 and 3
ajava.jdbc and javax.jdbe Type 3 and 4 d Type 4 only
Jjava.jdbc and java.jdb.sq a.13 Which of the following is false as far as
type 4
CRva.sql and javax.sql driver is concern?

java.rdb and javax.rdb a Type 4 driver is "native protocol, pure java"


4 driver
JDBC
nto howtechnology-based drivers nerally fit
b Type 4 drivers are 100 % Java compatible
many categories ?

b3
TM
Technical Publcations An up thrust for knowledsge
Autumndlaru Prynaremiry_ 5-118 Interac
acting
twith Data
y p e 4 drivers uses socket class to connect to the d| A DataSource is a factory of connection
nnections to a
physical data source.
database.
Q.19 Which of the following describes the
d Type 4 drivers can not be used with Netscape. the correc
sequence of the steps involved in ma
.14 Which of the following JDBC drivers is known
connection with a database. aking a
as a partially java driver ?
1. Loading the driver.
aDBC-ODBCbridge driver
2. Process the results.
bNative-APl driver 3. Making the connection with the database
eNetwork protocol driver the SQL statements.
4. Executing
dThindriver a 1,3,4.2 D1,2.34
a.15 Which class has strong support of the JDBC
architecture ? C2,1.3,4 d 4,1,2,3
a.20 Which of the following methods are needed
a The JDBC driver manager for
loading a database driver in JDBC?
b The JDBC driver test suite laregisterDriver() method
The DBC-ODBC bridge
b Class.forName()
d All of these and b
Q.16 In order to transfer data between a database cBoth a

and an application written in the Java dgetConnection)


the API Q.21 Which type of statement can execute
programming language, JDBC
provides which of these methods? parameterized queries?
aMethods on the ResultSet class for retrieving SQL a PreparedStatement
SELECT results as Java types. b ParameterizedStatement

bMethods on the PreparedStatement class for cCallableStatement b


sending Java types as SQL statement dAll of these
parameters. Q.22 What is used to execute parameterized query?

cMethods on the CallableStatement class for a Statement interface


retrieving SQL OUT parameters as Java types bPreparedStatement interface

dAll of these. Resultset interface


Q.17 The JDBC API has always supported persistent
defined in the Java
d None of the above
storage objects
of
Q.23 Which of the following encapsulates an SQL
the methods
programming language through statement which is passed to the database to
be
getObject and setObject.
parsed, compiled, planned and executed?
a True b False IDBC driver
a DriverManager
DataSource?
Q.18 What is, in terms of JDBC, a
Connection dStatement
aA DataSource is the basic service for managing a
Q.24 Which of the is used to call a stored
following
set of JDBC drivers.
procedure?

bA DataSource is the Java representation of a a Statement bPreparedStatement


physical data source.

DataSource is a registry pointfor JNDI


CallableStatment d CalledStatement

cA
services.

Technical Publications An up thrust for knowiedge


Tataas
you vall Interae sing with

Newlt vlfet ?
deletekuw() ona a.32 Toexee ute a ntatement, we invku metvw
o are
ositioned on
la deleted from lexerutetUpdate methow
heKeslt:et, but nol from the databane.
bwxecutelel method
1he
il ale positioned on la deleted from eexecutetMmt methon
and from the
databane.
Resultt

1heeultdeperuds on whether the property


dexecuteConn methd
Q.33 Method on resultset that tests whether o rar
ireWithDataSource is set to true
or
here remains at least one unfetched tuple in

talse
renult set, is said to be
You
a will get a compile error: 'The method doen a fetch method beurrent method
eist because you can not delete row» from next method d access method
a ResultSet.
Q.34 The ResultSet.next method is used to mowe tn
DBC-ODBC
bridge supports multple the next row of the Resultet, making it the
meurrent open statements per connectlon ? current row,

True bFalse a True False


a7 A raw data types (tor instance-data for a.35 ResultSet object can be moved forward only
intages) should be read and uploaded to the and it is updatable.
database as an array of_ a True False
a bvte b int a.36 Which JDBC drivers will run your prograrn ?

c/oolean d char a The JDBC-ODBC bridge.


a28 Are prepared statements actually compiled ? b The JDBC driver manager.
Nes, they compiled The JDBC driver test suite.
/No. they are bound by the JDBC driver d None of the above.
029 When the message "No Suitable Driver" Q.37 JDBC is a Java API that is used to connect and

Occurs? execute query to the database.


When the driver is not a True b False
registered by
Class.forname() method. Answers:
When the user name, password and the database
does not match.
1. 2 b 3.e4
5. a 6. d 7. d 8. b
When the JDBC database URL passed is not 9. d 10. b 11. a 12.
onstructed properly.
When the type 4 driver is used. 13.d 14.b 15. | a 16. d

30 Databasessystem
17. a 18. | d 19.a 20. c
compiles query when it is
exeuted binitialized
21.
a22.b23. d 24. d
prepared d invoked
25. b 26. | a 27.a 28. a
29. e 30.e 31.b 32. a
5 an open source DBMS product that runs
n
window as well as Linux.
33.
34a 35. b 36.
SPISQL b MySQL
37. a
MicTrosoft Access a sQL Server O00
Technical Publicetions
An up thrust for know/edge
6-22
Advanced Java Programming

3. The setAttribute(string attribute, object value) 15 a


cBoth a and b dNone of the eerds
the a.8 What is the lifecycle of a servlet?
method which assigns the value passed as
is loaded
The data type of aServlet class
object value to the attribute name.

Servlet instance is
created
this method is void. b
method is invoked
Review Question
Cinit, Service, destroy
1. Explain session management and cookies in servlet. d All of these
Q.9 What is the
difference between
Multiple Choice Questions Servlet andd
se

specificationdefines an applet?
Q.1 The Java.
application programming
interface for aservlets execute on servers while applets execute
communication between the web server and the on browser

application program bservlets create static pages while applets Teate

aservlet b randomise
dynamic pages
applet d script cservlets can execute Single request while applets
Q.2 Which method is used to specify before any execute multiple requests
lines that uses the PintWriter?
d None of these
asetPageType0 setContextType0
Q.10 A deployment descriptor describes
csetContentType0 ld]setResponseType0
a web component response settings
Q.3 What are the functions of Servlet container ?

aLifecycle management b web component settings


Communication support c web component request settings

cMultithreading support d All of these


Q.11 Which object is created by the web container at
All of the above time of deploying the
Q4 What is bytecode? project?
a Machine-specific code a ServietConfig ServletContext
CBoth aand b d None of the above
bJava code
Q.12 In HTTP Request method Get request s
eMachine-independent code
secured because data is exposed in URL bar
d None of the mentioned a True False
Q.5 What type of servlets use these methods
Q.13 Which class can handle any type of request so
doGet), doPost(), doHead, doDelete), that it is protocol-independent ?
doTrace)?
a Genereic Servlets HtpServlets GenericServlet b] HttpServlet
C Both a and b above
CAll ofthe above d None of these d None ofthe
Q.14 Servlet web
Q6 Web server is used for loading the init() technology is used to create
method of servlet. application
True False a Prue b False
of the
Q.7 Which packages represent interfaces and Q.15 The doGet() method extracts values
classes for servlet API? parameter's types and number by using-
a javax.servlet bJjavax.servlet.http a response.getAttribute0

Technical Publicatlons bresponse.getParameter)


An up thrust for
knowledge
tmdlja
arra
nPPrro
oggr
ramming

6-23 Servlets
eauest.getParameter()

Q.24 Which cookie it is valid for single session


a reque
est.setParameter)
and it is removed each time when the user cdoses
only
mic interception of requests and the browser ?
o 1 6

to ransform he information is done byresponse


aPersistent cookie Non-persistent cookie
Servlet Filter
bServlet Config cAll of these a None of these
Servlet Container |d Servlet Context
Q.25 Which method in sessiors tracking is used in a
a17
Thelife cycle of a servlet is managed by. bit of information that is sent by a web server to
a browser and which can later be read back from
hrtp and https b servlet context
that browser?
serviet itself
dservlet container
a18 hich method take a string not a URL?
HttpSession URL rewriting
sendRedirect bforward
efCookies Hidden form fields

Both dNone Answers


a19Which method shows the client what server is
1. a2.Je 3. d 4
receiving? 5.
b 6.a 7. c
doGet bdoOption 9. a 10. b 11.b 12 b
cdoTrace doPost 13. a
14. a 15.c 16. a

.20 What type of servlets use these methods 17. d 18. a 19. a 20. b
doGet(), doPost),doHead, doDelete(0
doTrace ? 21. a 22. c 23. a 24. b

Genereic Servlets HtpServlets 25. c


All ofthese d None of these Explanation
21 Which of the following are session tracking Q.12: The HTTP Request method Post is secured
techniques
ORL rewriting, using session object, using cookies,
using hidden fields
URL rewriting, using servlet object, using response
object, using cookies
CURL rewriting, using session object, using response
object, using hidden field
42 Which methods are used to bind the objects on
HtpSessiorn instance and get the objects?
a setAttribute b getAtribute
cBoth aand b dNone of the above
0.23 Sessions is part of the SessionTracking and it
side.
b tor
maintaining the client state at server
True DPalse

An up thrust for knowMedge


Technlcel Publications

You might also like