0% found this document useful (0 votes)
40 views50 pages

MSBTE AJP - ALL - MCQs Scheme I

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)
40 views50 pages

MSBTE AJP - ALL - MCQs Scheme I

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/ 50

Sr.

No Question Option A Option B Option C Option D ANSWERS

1 AWT stands for? All window Toolkit Abstract window Toolkit All writing Tools All windows Tools B

Labels, Push buttons, Check boxes, Text components, Threads, Strings, Labels, Strings, JSP, Netbeans, Push buttons, Servelts,
2 Which are various AWT controls from following? A
Choice, Lists Servelts, Vectors Sockets Notepad, JSP

3 Which of the following is the passive control? TextField Label Button Checkbox B

4 By calling _____________ method we add control in the window. Add() add() Insert() insert() B

We can remove a control from the window by calling_______


5 Del() Delete() Skip() remove() D
method

6 How Many Constructor are in Label? 1 2 3 4 C

7 Default Alignment in Label is____ Left Right Center Top A

8 Which of the following is not the constrcutor of label? Label() Label(String s) Label(int alignemnt) Label(String s, int alignment) C

9 return type of getText()? String void Icon int A

10 Return type of setText(String s)? String void Icon int B

11 Return type of getAlignemnt()? String void Icon int D

12 Return type of setAlignment(int Align)? String void Icon int B

13 AWT stands for? All window Toolkit Abstract window Toolkit All writing Tools All windows Tools B

14 Which method can be used to output a string in an applet display() print() drawString() transient() C

15 To disabled Label from applet which method is used? setEnabled(true) setEnabled(false) setDisabled(true) setDisabled(false) B

16 AWT is Platform dependent Platform independent both a and b none of these A

17 How Many Constructor are in Label? 1 2 3 4 C

18 Which of the following is not the constrcutor of Button? Button() Button(String s) Button(int aalign) none of these C

19 ____is the return type of getLabel() method of Button class String void Icon int A
20 return type of setLabel() is_______ String void Icon int B

21 To fetch caption of a button ____ method is used GetLabel() setLabel() getLabel() SetLabel() C

22 return type of getActionCommand() is __________ String void Icon int A

23 return type of actionPerformed() is ________ String void Icon int B

24 Action event is applied on button,textfield,List, Menu button,textfield,label textfield,button List,Menu A

Choose correct statement from following which implements


25 Button b1=Button("ok"); Button b1=new Button("ok"); both a and b none of these B
"create button with caption "ok" "

26 For creating a Button having label which constructor is used? Button(String str) Button(Icon i) Button(String str,Icon i) Button() A

27 return type of setVisible() void Int String Object A

28 ____class is at top of AWT hierarchy container Component window Panel B

________is a supe class for push button,checkboxes and


29 Button AbstractButton ScrollButton None of these B
radiobutton.

30 A __________ control is used to turn an option on or off. Button Label Checkbox List C

31 How Many Constructor are in checkbox? 1 2 3 4 C

32 return type of getState() is ______________ boolean Int String Object A

33 return type of setState(boolean state) is __________ boolean void String Object B

34 How many checkboxes we can check at a time one two Many None of these C

You can determine which checkbox is currently selected by calling


35 getselectedCheckbox() getSelectedCheckBox() GetSelectedCheckbox() getSelectedCheckbox() D
________ method

boolean setState(Boolean
36 CheckBox state can be changed by which method? void getSelected(Boolean state) boolean getSelected(Boolean state) void setState(Boolean state) C
state)

37 You can determine the checkbox name by which method? void getLabel() String getLabel() void getText() String getText() B

Which object is needed to group Checkboxes to make them


38 CheckboxGroup checkbox RadioButton TextField A
exclusive?

39 Which control is used to select only one option at a time in AWT? Checkbox CheckboxGroup RadioButton None of these B

40 return type of getselectedcheckbox() is_______ void string Checkbox boolean C


Which checkbox in a group is currently selected is determine by Checkbox
41 Checkbox getSelectedcheckbox() checkbox getSelectedCheckbox() Checkbox getselectedCheckbox() D
____________ method getSelectedCheckbox()

42 Which is immediate class of TextField? TextComponent TextArea Text none of these A

43 ___________ control is used for single-line entry. Text TextField TextArea TextGroup B

Which control allows user to enter string and edit the text using
44 textfield textarea both a and b none of these C
the arrow key, cut and paste keys.

45 How many constructor are present in TextField? 1 2 3 4 D

46 return type of getSelectedText() is ________________ boolean Int String Object C

47 return type of setEditable(boolean edit) is ______- void Int String Object A

48 Modification of text can be controlled by _____ method. setEditable(true) setEditable(false) seteditable(true) seteditable(false) B

49 return type of setEchoChar(char ch) void string boolean int A

50 return type of echoCharIsSet() void string boolean int C

51 ______can be used to enter or display a string Label Button Checkbox TextField D

52 return type if isEditable() ___ boolean string boolean int A

53 return type of getEchochar() is _____ boolean string char void C

disable the showing of the characters as they are typed using_____


54 void SetEchoChar(char ch) void setEchoChar(char ch) void setechoChar(char ch) void setechochar(char ch) B
method

55 how many constructors are present in TextArea? 2 6 5 3 C

56 Which of the following is not a TextArea constructor? TextArea(int row,int col) TextArea(String text) TextArea(String text,int column) TextArea() C

To construct a TextArea with text, rows and columns and scrollbar TextArea(String text, int rows,int TextArea(String text, int columns,int
57 both none of these A
which constructor is used? columns, int scrollbar) rows, int scrollbar)

TextArea(String text, int rows,int columns, int scrollbar) in these


58 1 2 3 4 D
constructor how many constant in scrollbar?

59 ___________ method is used to add a string at specified index. append() insert() add() replace() B

Only one item can be selected from Multiple item can be selected from
60 Following is true about list class both a and b none of these B
the list the list

Which of the following creates a List with 5 visible items and


61 new List(5,true) new List(5) New List(5,False) none of these A
multiple selection enabled?
62 How many constructors are in List? 1 2 3 4 C

63 Which of the following is not a List constructor? List() List(boolean mode) List(int rows) List(int rows, boolean mode) B

64 Which method is used to add new items in list void add(String item) Void Add(string item) both none A

which method returns the selected index and it returns -1 if no


65 SetSelectedIndex getSeletedIndex() GetSelectedValue() SetSelectedValue() B
item is selected?

Which method returns the selected value or display null if nothing


66 SetSelectedIndex GetSeletedIndex() getSelectedItem() SetSelectedValue() C
is selected

67 Which method determine the number of items from the list int GetitemCount() int getitemCount() int GetItemCount() int getItemCount() D

68 To set the currently selected item which method is used int select(int index) void select(int index) both None B

Which method returns the selected index or display-1 if nothing is


69 SetSelectedIndex getSeletedIndex() getSelectedItem() getseletedIndex() B
selected

70 Which methods determines the number of items from the list. GetItemCount() getitemCount() getItemcount() getItemCount() D

71 Return type of getSelectedIndex() of list is ________ string int void boolean B

72 Return type of getItemCoundt() of list is ___ string int void boolean B

73 Return type of getItem() of list is______- string int void boolean A

___ AWT componenet is used to create popup list of string items


74 List Choice scrollbar TextArea B
from which only one can be selected at a time

75 ___is the return type of getSelectedItem of choice class String int void object A

76 ___ is the return type of getSelectedIndex() of choice control int void string boolean A

for which class this method belongs to void


77 Choice Scrollbar List Button B
setValues(int,int,int,int)

78 AWT Viewer tool is available in which of the folder of JDK bin Lib Source class A

79 ____________ method is used to get current value of scrollbar. GetValue() getValue() get() Get() B

80 __________ method is used to set new value to scrollbar SetValue() setValue() set() Set() B

__________ method is get minimum value and ___________


81 getMinimum(),getMaximum() getminimum(),getmaximum() getMin(),getMax() getmin(),getmax() A
method get maximum value of scrollbar

82 How many constructors are in Choice? 1 2 3 4 A


83 How many constructors are in Scrollbar? 1 2 3 4 C

Scrollbar(int ori,int val,int


84 Which of the following is not a scrollbar constructor? Scrollbar() Scrollbar(int val) Scrollbar(int ori) B
size,int min,int max)

85 How many constructor are in frame? 1 2 3 4 B

86 Frame is a subclass of _________ class window panel container component A

Controls or components allow users Controls or components do not Controls or components allow users Controls or components allow
87 What are controls or components? application to interact with A
to interact with application allow users to interact with users to interact with users
user

88 Following return type of setTitle(args) void int String object A

89 Following is a return type of setVisible(args) void int String boolean A

90 Following class is at top of AWT hierarchy container component window Panel B

91 Which class is on the top of AWT event hierarchy? java.util.eventObject java.awt.event java.event none of these B

92 which method is used to check the status of the checkbox getState() GETSTATE() both a and b none of these A

93 To specify a font to be bold and Italic, use the font style value Font.PLAIN Font.BOLD+ITALIC Font.BOLD.ITALIC Font.BOLD+Font.ITALIC D

The method _________assign the name result to the Text of


94 jlbl.setText("Result") jlbl.newText("result") jlbl.text("Result") jlbl.findtext() A
variable jlbl.

95 Return type of getRGB()? color void int boolean C

96 Return type of setColor(Color newcolor) color void int boolean B

97 return type of getColor() color void int boolean A

The setBackground() method is a part of the following class in


98 Container Applet Object Graphics D
java.awt package

Which of the following methods can be used to remove


99 hide() disappear() remove() delete() C
java.awt.Component object from display?

100 ____ is the default layout manager for Panel or Applet Flow Layout Grid Layout Border Layout Card Layout A

101 Which method is used to set layout of the container setLayout() SetLayout() setlayout() none of these A

102 The general form to set a specific type of layout manager is void setlayout(layout manager ob) void SetLayout(layout manager ob) void setLayout(LayoutManager ob) none of these C

103 FlowLayout Consists of ___ alignments 1 2 3 4 C


FlowLayout(int align,in hgap,int FlowLayout(int hgap,int
104 Which of the following is not FlowLayout constructor? FlowLayout() FlowLayout(int align) D
vgap) vgap)

105 Default gap between the components is_______- 1 pixel 5 pixel 10 pixel 20 pixel B

106 Default Layout for Frame FlowLayout BorderLayout GridLayout Card Layout B

107 BorderLayout consist of ___static data members 5 4 3 2 A

108 Default layout manager for window is CardLayout FlowLayout BorderLayout GridLayout C

Which layout manager should you use so that every component


109 Flow Layout Grid Layout Border Layout Any Layout B
occupies the same size in the container?

Suppose a Jframe uses the GridLayout(2,0) If you add six Buttons


110 1 2 3 4 C
to the frame how many columns are displayed?

To layout the component in 2 dimensional array ____ layout is


111 CardLayout FlowLayout GridLayout BorderLayout C
used

112 _____ arrange components in rows and columns CardLayout Grid Layout FlowLayout BorderLayout B

Which of the following commands will set a layout manager that


113 setLayout(new GridLayout(4,3)) setLayout(new GridLayout(3,4)) GridLayout(4,3) GridLayout(3,4) A
divides the container into 3 columns and 4 rows?

Which layout aligns components horizontally and vertically and


114 BorderLayout CardLayout GridBagLayout GridLayout C
the components can be of different sizes

115 In cardLayout we are going to add component for every card to window Panel Frame container B

You can use method_______ on any instance of


116 SetForeground SetBackground SetFont SetLayout A,B,C
java.awt.component

117 Which methodd returns the face name of the invoking font? String getName() String SetName() String getFontName() String setFontName() C

118 ___is the return type of isBold() method of FONT class void boolean String TRUE B

119 is a return type of isBold () of Font class void boolean string TRUE B

Which class can be used to represent the Checkbox with a textual


120 MenuBar MenuItem CheckBoxMenuItem Menu C
label that can appear in a menu?

121 Which abstract class is a super class of menu related classes? menu menuclass Menu component none of these C

122 ____ method is used to add the menubar on frame window setMenuBar() addMenuBar() addMenu none of these A

123 Which of the following may a menu contain MaenuBar Menu both a and b none of these A

124 setEnabled(false); method used in menu item for _____ used to invisible menu item used to visible menu item used to select menu item none of these D
The concept of menu bar can be implemented by using three java
125 MenuBar Menu MenuItem all D
class:-

Which class can be used to represent the checkbox with


126 MenuBar MenuItem CheckboxMenuItem Menu C
textuallabel that can appear in a menu?

The arc is drawn counterclockwise if sweepAngle is _______ and


127 negative,positive negative,negative positive,positive positive,negative D
clockwise if sweepAngle is________

128 Which of these is super class of all adapeter class? Applet component Event Event InputEvent A

129 return type of addItem(Object obj) void string boolean int A

130 Types of dialog Boxes? Nodal & Nodeless Model & Modeless Modal & Nodal Both a & b B

Constructor of Dialog? A.Dialog(Frame parentwindow,boolean


131 mode) B.Dialog(Frame parentwindow,String title) A and B only C A and C only A C
C.Dialog(Frame parentwindow,String title,boolean mode)

which dialog box is active and input focus can be directed to


132 Model Modeless Both a and b none of these B
another window in the program.
In the constructor Dialog(Frame paretnwindow,boolean mode) the
133 parentwindow, is the owner of the dialog box.If mode is true then Model Modeless Both a and b none of these A
dialog box is?
Dialog(Frame paretnwindow,boolean mode) the parentwindow, is
134 Model Modeless Both a and b none of these B
the owner of the dialog box.If mode is false then dialog box is?

135 When dialog box is closed which method is called? exit() close() closed() dispose() D

136 How many constructors are present in FileDialog? 2 3 4 5 B

Method provided by FileDialog()? i. String getDirectory() ii.String


137 i and ii iv iii I,iii A
getFile() iii.String getDirectoryName() iv. Only iii
Sr.No Question Option A Option B Option C Option D Answer
1 Default Layout for Jframe FlowLayout BorderLayout GridLayout Card Layout B
2 Default Layout of Japplet FlowLayout BorderLayout GridLayout Card Layout B
How to obtain the command name for invoking getActionCommand( getActionEventCom
3 getActionEvent() getCommand() C
ActionEvent? ) mand()
What is return type of
4 int void boolean String B
actionPerformed(ActionEvent e)
Return type of itemStateChanged(ItemEvent
5 int boolean float void D
ie)
Return type of
6 void int string boolean A
removeActionListener(ActionListener el)
Model view Model viewer Modeless view Modeless viewer
7 MVC stand for? A
controller controller controller controller
MVC architeccture has 3 major parts, which is
8 Model Viewer View Controller A
the bottom most level of the MVC architecture
9 getContentPane() has return type? int String container void C
Platform
10 Swing is Platform dependent both a and b none of these B
independent
JLabel(String s,Icon i,int align) the align LEFT,RIGHT,CENT EAST,WEST,NORT TOP,BOTTOM,CEN RIGHT,LEFT,CENT
11 A
argument can be ER H,SOUTH TER ER,TOP,BOTTOM
Which of these methods cannot be called on
12 setIcon() getText() setLabel() setBordeLayout() D
JLabel object?
13 How many constructors of JLabel present? 1 2 3 4 D
14 return type of setHorizontalAlignment(int a) void int string boolean A
15 return type of setIcon(Icon i) void int string boolean A
16 How many constructors of icons present? 2 3 4 5 A
17 ImageIcon class implements? Icon class Icon Interface Image class Image Interface B
int getIconHeight() returns the height of the
18 inches centimeter pixels milimeter C
icon in?
19 return type of getIcon()? string void Icon int C
20 return type of setIcon(Icon i)? string void Icon int B
Which of the following are constructor of ImageIcon(String
21 ImageIcon(URL url) both none of these C
ImageIcon? filename)
Constructor of JButton class? i.JButton(Icon i)
ii.JButton(String s) iii.JButton(String s,Icon i)
22 i,ii,iii i,ii,iv,v i,ii,iv all of these A
iv.JButton(Image j) v.JButton(String s,Icon
i,Image j)
For creating a JButton having label which JButton(String
23 JButton(String str) JButton(Icon i) JButton() A
constructor is used? str,Icon i)
Which method is used to display icon on a new
24 setIcon(ImageIcon i) Icon("a.gif") none of these B
JButton component? ImageIcon("a.gif")
Sr.No Question Option A Option B Option C Option D Answer
Which package is used to import swing import import
25 import java.swing; import Java.Swing.*; C
component JavaX.Swing.*; javax.swing.*;
Which among below is not the method
26 setDisableIcon() setPressedIcon() setSelectedIcon none of these D
applicable for Button in swing
27 Model is ______ of MVC architecture top most level bottom most level middle level none of these B
28 How many constructors are of JButton? 2 3 4 5 C
29 How many constructors are of JTextField? 2 3 4 5 C
30 return type of setRolloverIcon(Icon i) void int string boolean A
31 Swing uses for running GUI application? Applet JApplet Both a and b none of these B
The Method_____ sets the background color to SetBackground(Col f.SetBackground(Co f.setbackground(col setbackground(color
32 B
yellow in Jframe f or.yellow) lor.YELLOW) or.yellow) .yellow)
Which of these is a super class of all adapter
33 Applet Event ComponentEvent InputEvent A
class?
To use Swing components_____ package is
34 java.Swing javax.swing java.awt javax.awt B
used
____component can be given their own look
35 AWT Swing both a and b none of these B
and feel
____component allows us to enter/edit a single
36 JTextField JTextArea Both a and b none of these A
line of text
_____component is used to accept several
37 JTextField JTextArea Both a and b none of these B
lines of text from the user
38 How many constructors are of JTextArea? 2 3 4 5 C
Which method is called to obtain a reference to
39 getItem() getText() getSelectedItem() none of these C
the JCheckBox object that generate the event
40 How many constructors are of JCheckBox? 5 6 7 8 C
41 Which of the following is not a swing class canvas Frame Window All of these A
The method _________create a ImageIcon new ImageIcon new ImageIcon new ImageIcon
42 none of these B
from file c:\image\us.gif ("c:\image\us.gif") ("c:\\image\\us.gif") ("c:\image\US.gif")
43 What 'C' specifies in MVC architecture controller Control both a and b none of these A
title bar, border,
By default the Frame has a title bar, border,
44 title bar, border resizing corner resizing corner, A
_________________ resizing corner
color
45 How many constructors are of JRadioButton? 5 6 7 8 C
46 In swing Radio Button created using CheckBoxGroup JButton ButtonGroup none of these D
_____________ pane can be used to add
47 GlassPane ContentPane Container All of above B
component to container
48 Swing uses for running GUI application? Applet JApplet Both a and b none of these B
Sr.No Question Option A Option B Option C Option D Answer
__are known as option button as you can
49 select only one option or button at a time in a Button RadioButton Both a and b None of these B
given group of options.
Which component cannot be added to a
50 Jpanel Jbutton Jframe Jcomponent C
container?
_____ interface define a method
51 Component Listener Container Listener Action Listener Item Listener D
itemStateChanged()
AWT classes can be roughly categorized into
52 GUI components Layout Graphics tools All of these D
the following groups
____ is a combination of textfield and
drop-down list that lets user either type in a
53 JComboBox JTabbedPane JScrollPane Jtree A
value or select it from a list that is displayed
when the user asks for it.
Which control in swing is a combination of
54 Jlabel JCheckBox JComboBox Jlist C
textfield and dropdown list?
Swing provides a combo box (a combination of
55 text field and drop down list) through the Jcomponent Jpanel Jcontainer Jlabel A
JcomboBox class, which extends ____
Which is control in swing a combination of a
56 JComboBox Jchoice JLabel Jlist A
text field and a dropdown list
57 How many constructors are of JComboBox()? 1 2 3 4 B
A ____ is a component that appears as a
58 group of folders in a file cabinet. Each folder JComboBox JScrollPane JTabbedPane Jtree C
has a title
59 How many constructors are of JTabbedPane()? 1 2 3 4 C
In JTabbedPane default Tab Placement is
60 TOP LEFT RIGHT BOTTOM A
_______
A____ is a component that presents a
61 rectangular area in which a aomponent may be JComboBox JTabbedPane JScrollPane Jtree C
viewed.
void
to add Tab in TabbedPane which method is void addTab(String void add(String s,
62 addTab(component none of these A
used? s, component c) component c)
c,String s)
63 addTab() belongs to JTabbedPane JScrollBar Jlist All of these A
64 return type of getPath() String int TreePath float C
DefaultMutableTreeNode implements which TreeSelectionListen
65 MutableTreeNode both a and b none of these B
interface er
JTable object JTable object JTable object JTable object
66 What is the purpose of JTable? displays rows of displays columns of displays rows and displays data in C
data. data. columns of data. Tree form
Which method is used to display icon on a rollOverIcon( displayIcon(ImageIc removeIcon
67 setIcon(ImageIcon i) B
component? ImageIcon i) on i) (ImageIcon i )
Sr.No Question Option A Option B Option C Option D Answer
_____ method returns string of items which is
68 getItem() getSelectedItems() GetSelectedItem() none of these B
currently selected.
Frame is a standard window, which is ____ of
69 Super class subclass both a and b none of these B
window class from AWT hiereachy
70 the default orientation of JProgressBar is ____ Vertical Horizontal both a and b none of these B
You can contruct a JTabbedPane using
71 new JTabbedPane() new TabPane() new jtabbedpane() new tabpane() A
________
JTabbedPane class is present in which
72 java.tabbedPane javax.tab javax.Swing javax.swing D
package?
The AWT container is an instance of the ____
73 class which holds various components and Graphics Component Panel all of these B
other containers
Which method to specify the text for standard
74 setToolTipText() setText() SetToolTip() SetToolText() A
tooltip.
Which method is used to disply titlebar of
75 setTitle(String this) Title(String this) both a and b none of these A
frame
When layout manager is disabled, which
76 methods is used to determine the shape and setBounds setSize both a and b none of these A
position of component?
Sr.No. Question Option A Option B Option C Option D Answer
Which of these events generated when a button is
1 WindowEvent ActionEvent KeyEvent ActionEvent B
pressed B
2 Method use to change the location of event? getPoint() translatePoint() getClickCount() isPopupTrigger() B B
Which method will be invoked if a character is
3 KeyPressed() KeyReleased() KeyTyped() KeyEntered() C
entered? C
4 Which of these is a super class of all adapter class? Applet Event ComponentEvent
InputEvent A A
Which method used to obtain co-ordinates of a GetMouseCoordi
5 getPoint() GetCoordinates() GetMouseXY() A
mouse nates() A
Which of these is a super class of all
6 WindowEvent ComponentEvent ItemEvent InputEvent B
ContainerEvent class? B
7 Which of these class is super class of all events? EventObject EventClass AcctionEvent ItemEvent A A
8 ____is a superclass of windowEvent class WindowEvent ComponentEvent ItemEvent InputEvent B B
Which of these package contains all the event
9 java.lang java.awt java.awt.event java.event C
handling interfaces? C
ActionEvent,Co ContainerEvent, ItemEvent,KeyE
10 Name of event classes? All of these D
mponentEvent FocusEvent vent D
11 Event object class belongs to java.util java.awt java.lang java.sql A A
_____method is defined in mousemotionAdapter
12 MouseDragged() MousePressed() MouseReleased() MouseClicked() A
class A
Which of these constant value will change when the
BLOCK_DECR BLOCK_INCRE UNIT_DECRE UNIT_INCREM
13 button at the end of scrollbar was clicked to D
EMENT MENT MENT ENT
increase its vvalue? D
Which constant of window Event class makes a WINDOW_CLO WINDOW_CLO WINDOW_ACT WINDOW_DEA
14 B
request for closing window SED SING IVATED CTIVATED B
AdjustmentListe
15 ScrollBar implements____ MousseListener ItemListener WindowListener A
ner A
For which Interface method belongs to void AdjustmentListe ComponentListe
16 ObjectListener ActionListener B
adjustmentValueChanged(AdjustmentEvent e) ner ner B
For which class this constant belongs to
17 BLOCK_DECREMENT and scrollbar menubar filedialog actionevent A
BLOCK_INCREMENT A
Which of these events is generated when the size of
18 ComponentEvent ContainerEvent FocusEvent InputEvent A
component is changed? A
Which of these events is generated when the
19 ComponentEvent ContainerEvent FocusEvent InputEvent B
component is added or removed? B
Which of these are integer constants of COMPONENT_ COMPONENT_ COMPONENT_
20 all of these D
ComponentEvent class? HIDDEN MOVED RESIZE D
Which of these events is generated when computer Component
21 Container Event Focus Event Input Event C
gains or losses input focus? Event C
22 Base class of all AWT Event class is AwtEvent KeyEvent ActionEvent AdjustmentEvent A A
Sr.No. Question Option A Option B Option C Option D Answer
Which of these event generated when a button is
23 window Event ActionEvent KeyEvent mouseEvent B
Pressed? B
Which is the class responsible for handling key
24 KeyEvent window Event ActionEvent mouseEvent A
press activity A
25 Event class library is define in following package java.io java.util java.event java.object B B
26 ComponentEvent is a super class of __________ Container Event FocusEvent both a and b none of these C C
TEXT_VALUE_
27 TextEvent defines integer constant TEXT_VALUE both a and b none of these A
CHANGED A
____ is the abstract super class of all component
28 KeyEvent ItemEvent ActionEvent InputEvent D
input event class D
change in the change in the
29 Event is called as both a and b none of these A
state of object state of variable A
A listener is a
is a variable that is an object that
method that is
30 What is listener in context to event handling? is notified when is notified when none of these B
notified when an
an event occurs an event occurs
event occurs B
31 Event class is defined in which of these libraries java.io java.lang java.net java.util D D
Which of these method are used to register a ADDKeyListene addKeyListener( eventKeyboardLi
32 KeyListener() C
keyboard event listener? r() ) stener() C
Which of these method can be used to obtain the getActionComm getActionEventC
33 getCommand() getActionEvent() B
command name for invoking actionEvent object? and() ommand() B
Which of these events will be generated if we close
34 ActionEvent ComponentEvent AdjustmentEvent WindowEvent D
an applet's window? D
Which of these integer constants defines in
35 ALT_MASK CTRL_MASK SHIFT_MASK All of these D
ActionEvent class D
Which of these method can be used to determine
36 getID() getSource() getEvent() getEventObject() A
the type of event? A
37 Which of these class is super class of all the events? EventObject EventClass ActionEvent ItemEvent A A
Which of these method can be used to know the getAdjustmentTy getAdjustmentVa getAdjustmentA
38 getValue() A
degree of adjustment made by the user? pe() lue() mount() A
Which of these methods can be used to determine getAdjustmentTy getEventObjectT
39 getType() getEventType() C
the type of adjustment event? pe() ype() C
Which of these methods can be used to obtain the
getCiontainerCo getContainerEve
40 reference to the container that generated a getContainer() getActionEvent() D
mmand() nt()
containerEvent? D
Which of these constant value will change when the
BLOCK_DECR BLOCK_INCRE UNIT_DECRE UNIT_INCREM
41 button at the end of scrollbar was clicked to D
EMENT MENT MENT ENT
increase its value? D
Which of these methods can be used to know which GetActionEvent(
42 getKey() getModifier() getActionKey() B
key is pressed? ) B
Sr.No. Question Option A Option B Option C Option D Answer
Which of these methods can be used to obtain the getMouseCoordi
43 getPoint() getCoordinates() GetMouseXY() A
coordinates of a mouse? nates() A
Which of these is superclass of container Event
44 windowEvent ComponentEvent ItemEvent ItemEvent B
class? B
Which of these events is generated when computer
45 ComponentEvent ContainerEvent FocusEvent InputEvent C
gains or loses input focus? C
Which of these methods will respond when you
46 mouseClicked() mouseReleased() mousePressed() All of these D
click any button by mouse? D
Which of these interfaces defines a method ComponetListen ContainerListene
47 ActionListener InputListener C
actionPerformed()? er r C
48 Which of these is superclass of all adapter classes? Applet ComponentEvent Event InputEvent A A
Which of these methods will beinvoked if a
49 keyPressed() keyReleased() keyTyped() keyEntered() C
character is entered? C
____method are used to register a mousemotion addMouseListen addMouseMotio eventMouseMoti
50 addMouse() C
listener er() nListener() onListener() C
51 In which library event class is defined? java.io java.util java.lang java.net B B
52 ___is super class of all the events. EventObject EventClass ActionEvent ItemEvent A A
If scrollbar is manipulated ____ event will be
53 ActionEvent ComponentEvent AdjustmentEvent WindowEvent C
notified. C
which of these events is generated when a button is
54 ActionEvent keyEvent windowEvent AdjustmentEvent A
pressed? A
____method can be used to determine the type of getAdjustmentTy getEventObjectT
55 getType() getEventType() C
adjustment event. pe() ype() C
When the size of component is changed, ____ event
56 ComponentEvent ContainerEvent FocusEvent InputEvent A
is generated. A
When the component is added or removed, which
57 ComponentEvent ContainerEvent FocusEvent InputEvent B
of these events is generated. B
____method can be used to obtain the reference to getcontainerCom getContainerEve
58 getContainer() getActionEvent() D
the container that generated a container. mand() nt() D
which of the following method can be used to get
getcontainercom getcomponentCh
59 reference to a component that was affected by the getcomponent() getChild() B
ponent() ild()
container? B
____event is generated when computer gains or
60 ComponentEvent ContainerEvent FocusEvent InputEvent C
losses input focus. C
61 FocusEvent is a subclass of _____ classes. ComponentEvent ContainerEvent ItemEvent InputEvent C C
typeEventFocus(
62 ___can be used to know the type of focus change. typeFocus() isTemporary() isPermanent() A
) A
___method can be used to change location of an ChangeCoordina TranslateCoordin
63 ChangePoint() translatePoint() B
event. tes() ates() B
Sr.No. Question Option A Option B Option C Option D Answer
Which of the following is integer constant of TEXT_CHANG TEXT_FORMA TEXT_VALUE_ TEXT_SIZE_C
64 C
TextEvent class? ED T_CHANGED CHANGED HANGED C
___is used to obtain the object that generated a getWindowEvent getWindowObjec
65 getMethod() getWindow() B
windowEvent. () t() B
66 MouseEvent is subclass of___classes. ComponentEvent ContainerEvent ItemEvent InputEvent D D
___method is used to get X coordinates of the getXCoordinate( getCoordinateX(
67 getX() getPointX() A
mouse. ) ) A
which of these are constants defined in WINDOW_ACT WINDOW_CLO WINDOW_DEI
68 All of these D
windowEvent class? IVATED SED CONIFIED D
69 ___is superclass of windowEvent class. windowEvent ComponentEvent ItemEvent InputEvent B B
ComponentListe ContainerListene
70 Which of the following interface define 4 Methods? ActionListener InputListener A
ner r A
Which methods will respond when you click any
71 mouseClicked() mouseEntered() mousePressed() All of these D
button by mouse? D
Which of these packages contains all the classes
72 java.applet java.awt java.event java.awt.event D
and methods required for even handling in Java? D
Which of these methods are used to register a addMouseListen addMouseMotio eventMouseMoti
73 addMouse() C
mouse motion listener? er() nListener() onListener() C
Which of these methods can be used to determine
74 getID() getSource() getEvent() getEventObject() A
the type of event? A
Which of these events will be notified if scroll bar
75 ActionEvent ComponentEvent AdjustmentEvent WindowEvent C
is manipulated? C
Which of these event is generated when a button is
76 ActionEvent keyEvent windowEvent AdjustmentEvent A
pressed? A
An event is an An event is an An event is an
An event is a
object that object that object that
What is an event delegation model used by Java class used for
77 describe a state describe a state describe a any A
programming languages? defining object,
change in a change in a changes by the
to create events.
source. processing. user and system A
Which of these methods can be used to obtain the getActionComm getActionEventC
78 getCommand() getActionEvent() B
command name for invoking ActionEvent object? and() ommand() B
79 Which of these event is generated by scroll bar? ActionEvent keyEvent windowEvent AdjustmentEvent D D
Which of these packages contains all the event
80 java.lang java.awt java.awt.event java.event C
handling interfaces? C
Which of these interfaces handles the event when a ComponentListe ContainerListene
81 FocusListener InputListener B
component is added to a container? ner r B
ComponentListe ContainerListene
82 Which of these interfaces defines four methods? FocusListener InputListener A
ner r A
Which of these interfaces defines a method ComponentListe ContainerListene
83 FocusListener ItemListener D
itemStateChanged()? ner r D
Sr.No. Question Option A Option B Option C Option D Answer
Which of these methods is defined in
84 mouseDragged() mousePressed() mouseReleased() mouseClicked() A
MouseMotionAdapter class? A
Which of these are integer constants defined in
85 ALT_MASK CTRL_MASK SHIFT_MASK All of these D
ActionEvent class? D
Which of these methods can be used to know the getAdjustmentTy getAdjustmentVa getAdjustmentA
86 getValue() A
degree of adjustment made by the user? pe() lue() mount() A
Which of these events is generated when the size of
87 ComponentEvent ContainerEvent FocusEvent InputEvent A
an event is changed? A
Which of these events is generated when the
88 ComponentEvent ContainerEvent FocusEvent InputEvent B
component is added or removed? B
Which of these methods can be used to get
getcontainercom getcomponentCh
89 reference to a component that was removed from a getcomponent() getChild() B
ponent() ild()
container? B
Which of these are integer constants of COMPONENT_ COMPONENT_ COMPONENT_
90 All of these D
ComponentEvent class? HIDDEN MOVED RESIZE D
Which of these events is generatd when computer
91 ComponentEvent ContainerEvent FocusEvent InputEvent C
gains or losses input focus? C
Which of these event is generated when window is
92 TextEvent MouseEvent FocusEvent WindowEvent D
closed? D
which of these methods can be used to change ChangeCoordina TranslateCoordin
93 ChangePoint() translatePoint() B
location of an event? tes() ates() B
ComponentListe ContainerListene
94 Interface used to handle menu event is ActionListener ItemListener A
ner r A
The Key Event class doen not define _______ KEY_RELEASE KEY_ENTERE
95 KEY_PRESSED KEY_TYPED D
integer constant D D D
_____ is the abstract super class of all component
96 FocusEvent InputEvent ComponentEvent ContainerEvent B
input event class. B
FocusEvent are fired whenever a component _____
97 add or remove gain or loses both a and b none of these B
the focus B
If a class extends ActionListener interface, it must itemStateChange
98 actionPerformed both a and b none of these A
contain a method called ______ d A
Which of these Listener handles all List related ComponentListe ContainerListene
99 ItemListener ActionListener C
Events ner r C
Which of the following statements registers a panel addActionListen jbt.addActionList jbt.addEventActi jbt.EventListener
100 B
object p as a listener for a button variable jbt? er(p) ener(p) onListener(p) (p) B
Button, textFiel, Button,TextField,
101 Action event is applied on Button, Menu TextField,Menu A
text , menu Label A
Mouse_CLICKE Mouse_Dragged(
102 Which method is used to processes mouse click? Mouse_Moved() All A
D() ) A
Which of these methods can be used to determine
103 getID() getSource() getEvent() getEventObject() A
the type of event? A
Sr.No. Question Option A Option B Option C Option D Answer
Which of the following is not one of the seven WindowActivate
104 windowOpening WindowIconified WindowClosed A
methods for handling window events? d A
Which of these method will respond when you click
105 mouseDragged() mousePressed() mouseEntered() all D
any button by mouse D
Adapter classes are similar to EventListener
106 TRUE FALSE B
interfaces B
Sr. No. Question Option A Option B Option C Option D Answer
How many ports of TCP/IP are reserved for specific
1 10 1024 2048 512 B
protocols?
Which of these package contains classes and interfaces for
2 java.io java.util java.net java.network C
networking?
Which of these class is used to encapsulate IP address and DatagramPac ContentHandl
3 URL InetAddress C
DNS? ket er
4 How many bits are in a single IP address? 8 16 32 64 C
5 In the format for defining URL what is the last part? Port number Host name File Path Protocol C
6 TCP and UDPs Protocol function interface None of these A
7 ____ method is used to retrive file name in specified URL. getFileName() retrieveFile() getFile() getData() C
Which exception indicate that the IP address of a host could HostNotFoun UnknownHost
8 Both none of these B
not be determined dException Exception
9 Port number of HTTP is ___ 80 53 110 119 A
Universal Uniform
10 what is longform of URL? Resource Resource Both None of these B
Locator Locator
11 Port number of Telnet is ____ 21 23 25 1020 B
12 InetAddress class has no visible constructors TRUE FALSE A
13 ___ method is used to retrive file name in specified URL. retriveFile() getFile() getRef() None of these B
14 Which of the following connection oriented protocol? HTTP IP UDP All of above A
The factory method which returns an array of InetAddress
getLocalHost( getAllByNam
15 that represent all of the addresses that a particular host name getByName() None of these C
) e()
resolves to.
16 Port number of Email is ____ 22 1020 23 25 D
The ___ method simply returns the InetAddress object that getLocalHost( getAllByNam
17 getByName() None of these A
repersents the local host. ) e()
18 What is the first part of URL address? Host Name Port Number File Path Protocol D
URL(String
URL(String
protocolName
protocolName
, String URL(String
19 select the proper constructor of URL class , String All of above D
hostName, urlSpecifier)
hostName,
intport, String
String path)
path)
Which of these exception is thrown by URL class’s URLNotFoun URLSourceN MalformedU URLNotFoun
20 C
constructors? d otFound RLException dException
21 Which of these methods is used to know host of an URL? host() getHost() GetHost() gethost() B
//What is the output of this program
import java.io.*;import java.net.*;
public class networking

{
public static void main(String args[]) throws
UnknownHostException
22 { 0 1 true false C
InetAddress obj1=InetAddress.getByName("google.com");
InetAddress obj2=InetAddress.getByName("google.com");
Boolean x=obj1.equals(obj2);
System.out.println(x);
}
}

//Consider the following program


//What will be displayed in the output?
import java.net.*;
class m
{
public static void main (String args[])
{
try{ The internet The internet The internet The internet
23 InetAddress address = InetAddress.getLocalHost(); address of the address of the address of the address of any C
System.out.println(address); server client host other PC
}
catch (UnknownHostException e)
{
System.out.println("Could not find this computer's
address.");
}}}
Consider the following program
What correction should be done in the program to get
correct output?
import java.net.*;
import java.io.*;

public class URLTest


{
public static void main(String args[]) throws Creation of Use of created
Exception Class should
24 MalformedURLException object is not object not D
type is wrong. not be public
{ correct correct
URL url = new URL("http://www.msbte.com/download");
System.out.println("Protocol:"+ url1.getProtocol());
System.out.println("Port:"+ url1.getPort());
System.out.println("Host:"+ url1.getHost());
System.out.println("File:"+ url1.getFile());
}
}
Consider the following program.
Which statement should be added to get correct output?

import java.io.*;
import java.net.*;
import java.util.Date;
public class udemo
{
public static void main(String args[]) throws
MalformedURLException, IOException
{
URLConnecti URLConnecti URLConnecti URLConnecti
int c;
on u1 = on u1 = on u = on =
25 long d; B
openConnecti u.openConnec u.openConnec u.openConnec
URL u = new URL("http://www.msbte.com");
on(); tion(); tion(); tion();
String s = u1.getContentType();
System.out.println("Content type:"+s);
d= u1.getDate();
System.out.println("Date:"+new Date(d));
InputStream ip = u1.getInputStream();

while((c = ip.read())!=-1)
System.out.print((char)c);
}
}

For the following code select the missing statement


import java.net.*; public class DemoInetAddress { public
static void main(String args[]) _________ { InetAddress
throws throws
address;String hostname,hostaddrs;
26 MalformedU UnknownHost both a and b None of these B
address=InetAddress.getByName("Comp12");
RLException Exception
hostname=address.getHostAddress();
System.out.println("Host name="+hostname);
System.out.println("Hostaddress="+hostaddrs);}}
Consider the following program fill in the blanks
import java.net.*; import java.io.*; public class URLTest
{public static void main(String args[]) throws
URLConnecti
MalformedURLException { _____ ob=new
on, URLConnecti URL,URLCo
27 _____("http://www.msbte.com/download");System.out.prin URL,URL B
URLConnecti on, URL nnection
tln("Protocol="+ob.getProtocol());
on
System.out.println("Port="+ob.getPort());
System.out.println("Host="+ob.getHost());
System.out.println("File="+ob.getFile());}}
import java.net.*; class import java.net.*; class
URLDemo { public static URLDemo { public static
void main(String args[]) void main(String args[])
throws throws
MalformedURLException { MalformedURLException {
For the following output, which method is used in program: URL hp= new URL hp= new
28 A
Protocol:http Port: -1 URL("http://www.osborne.co URL("http://www.osborne.co
m/downloads"); m/downloads");
System.out.println("Prorocol: System.out.println("Prorocol:
"+hp.getProtocol()); "+hp.getProtocol());
System.out.println("Port:"+hp System.out.println("Port:"+hp
.getPort());}} .GetPort());}}
//What is the compile time error in the following program?
import java.net.*;
class InetAddressInstanceMethodDemo
{
public static void main(String args[]) throws
UnknownHostException
Missing cannot find missing No compile
29 { D
semicolon symbol header time error
InetAddress address=InetAddress.getLocalHost();
System.out.println(address.equals(address));
System.out.println(address.getAddress());
System.out.println(address.getLocalHost());
System.out.println(address.isMulticastAddress());
System.out.println(address.toString());} }
//What is the error in given code?
import java.net.*;
public class Hostname
{
public static void main(String args[])
{
try
Missing cannot find missing None of
30 { B
semicolon symbol header above
InetAddress local=InetAddress.getLocalHost();
System.out.println("Local Host Name is:-"+
local.getLocalHostName());
}
catch(UnknownHostException e)
{ System.err.println("Can't detect localhost:"+e);
}}}
select proper method to compile & run the code: import
C:\jdk1.2.2\bi C:\jdk1.2.2\bi
java.net.*; class sample { public static void main(String []
n>javac n>javac
args) throws Exception {URL obj=new None of
31 sample.java sample both a and b A
URL("http://www.msbte.com"); URLConnection above
C:\jdk1.2.2\bi C:\jdk1.2.2\bi
obj1=obj.openConnection(); int
n>java sample n>java sample
len=obj1.getContentLength();System.out.print(len);}}
What is the output of the following code import java.net.*;
class networking { public static void main(String args[])
http://www.go www.google.c
32 throws MalformedURLException { URL obj=new google.com none of these A
ogle.com om
URL("http://www.google.com");
System.out.print(obj.toExternalForm());}}
What is the output of this program?

import java.net.*;
class networking
{
public static void main(String[] args) throws
33 MalformedURLException http https www com A
{
URL obj = new
URL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.getProtocol());
}
}
What is the output of this program?

import java.net.*;
class networking
{
public static void main(String[] args) throws
34 MalformedURLException 0 1 -1 garbage value C
{
URL obj = new
URL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.getPort());
}
}
What is the output of this program?

import java.net.*;
class networking
{
public static void main(String[] args) throws http://www.sa
sanfoundry.co www.sanfoun
35 MalformedURLException sanfoundry nfoundry.com/ C
m dry.com
{ javamcq
URL obj = new
URL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.getHost());
}
}
What is the output of this program? * import​java.net.*; *
class​networking { * public​static​void​main(String[] args)
throws​Exception { * URL obj = new
36 html text html/text text/html D
URL("http://www.sanfoundry.com/java mcq"); *
URLConnection obj1 = obj.openConnection(); *
System.out.print(obj1.getContentType() ); * } * }
37 How many bits are in a single IP address? 8 16 32 64 C
What is the output of this program import
java.io.*;
Class networking
Public static void main(String args[]) throws
UnknownHostException
38 { a a.com www.a.com None of these B
InetAddress obj1=InetAddress.getByName(“a.com”);
System.out.println(obj1.getHostName());
}
}

To access attributes of remote host which of the following URL DatagramSoc


39 URL None of these B
class is used Connection ket
void int
Select the proper method for retriving the content length of
40 getContentLe getContentLe Both None of these B
URL
ngth() ngth()
41 byte[] getData() method is defined by ____ class Datagram server clientsocket None of these A
_____ class is used for accessing the attributes of a remote ConnectionCl URLConnecti
42 URL Class server class D
resource ass on Class
ConnectionOb
43 What does openConnection() returns? URL object URL object File Object A
ject
getHostAddre getHostName(
44 ___ are the instance methods of InetAddress class. getAddress() All of above D
ss() )
URLConnecti
45 OpenConnection() method returns _____ URL object File Object None of these C
on object
URLconnection, socket,InetAddress are part of which
46 java.io java.awt java.net None of these C
package.
returns remote find out
port to which protocol for
47 what is the function of getPort()? Both None of these A
socket object communicatio
is connected. n
Which exeception is thrown by InetAddress class when it UnknownExc MalformEsce UnknownHost
48 none of these C
cant resolve the name of address? eption ption Exception
The abstract class ___ is the super class of all classes that URLConnecti
49 URL Both None of these B
represent a communication link between application and url on
URL(String
URL(String
protocolName
protocolName
, String URL(String
50 Which of the following is not correct constructor of URL? , String None of these D
hostName, urlSpecifier)
hostName,
intport, String
String path)
path)
What is the output of this program?
import java.net.*;
class networking {
public static void main(String[ ] args throws exception {
URL obj = new URL (http://www.msbte.com/javamcq);
51 html text html/text text/html D
URLConnection obj1=obj.opemConnection();
System.out.print(obj1.getContentType());
}
} note:Host URL is written in html and simple text;
static static
static InetAddressge InetAddress[ ]
InetAddressge tByName(Stri getAllByNam
string
Select the proper method for retriving the host name of tLocalHost( ng e(String
52 getHostAddre A
local machine )throws hostName)thr hostname
ss()
UnknownHost ows throws
Exception UnknownHost UnknownHost
Exception Exception
Consider the following program.
Which statement should be added to get correct output?

import java.io.*;
import java.net.*;
public class udemo
{
public static void main(String args[]) throws
MalformedURLException, IOException
{
int c;
long d; import import import import
53 B
URL u = new URL("http://www.msbte.com"); Java.awt.*; java.util.Date; java.sql.*; java.thread.*;
String s = u1.getContentType();
System.out.println("Content type:"+s);
d= u1.getDate();
System.out.println("Date:"+new Date(d));
InputStream ip = u1.getInputStream();

while((c = ip.read())!=-1)
System.out.print((char)c);
}
}
Fill in correct code at blank space:- import java.net.*;
public class getDatagramExample { public static void
main(String args[]) { String s="This is a test"; byte{}
data=new byte[s.length()]; s.getBytes(0,s.length(),data,0);
try { InetAddress
ia=InetAddress.__________("www.msbte.com"); int
getName, getByName, getByName, getByName,
port=7; DatagramPacket dp=new
54 UnknownHost UnknownExc UnknownHost UnknownHost C
DatagramPacket(data,data.length,ia,port);System.out.println
Exception eption Exception exception
("This packet is addressed to "+dp.getAddress()+"on
port"+dp.getPort());System.out.println("There are"
+dp.getLength()+"bytes of data in the
packet");System.out.println(new
String(dp.getData(),0,0,dp.getLength()));}
catch(___________ e){System.err.println(e);}}}
What is the output of the following code if Host URL was
last modified on June 18 Tuesday 2013. import java.net.*;
class networking { public static void main(string args[])
Tue Jun 18
55 throws Exception { URL obj=bew URL("http:// 0 1 None of these A
2013
www.sanfoundry.com/javamcq"); URLConnection
obj1=obj.openConnection();System.out.print(obj1.getLastM
odified);}}
Which of these are protocol for breaking and sending packets to
56 TCP/IP DNS Socket Proxy Server A
an address across a network?
Domain
Data Network Data Name Domain Name
57 Which of these is a full form of DNS? Network D
Service Service Service
Service
the server
the server is
java.net.BindE the server is encounteres a
blocked until
58 When creating a server on port that is already in use, ______ xceptionError created with no fatal error and A
the port is
occur problem must be
available
terminated.
the client can
the client
connect to the the client is
java.net.BindE encounteres a
server blocked until
59 When creating a client on a server port that is already in use,___ xceptionError fatal error and A
regardless of the port is
occur must be
whether the available
terminated.
port is use.
Socket s= new Socket s= Socket s= Socket s= new
the client request a connection to a server using the following
60 Socket(servern serverSocket.ac serverSocket.ge Socket(servern A
statement:
ame, port); cept(); tSocket(); ame);
Which method of serverSocket will wait for a client to initiate
61 accept() wait() resume() None of these A
communication and then communicate with the client
Which of these methods of DatagramPacket issued to obtain the
62 getData() getBytes() getArray() receiveBytes() A
byte array of data contained in a datagram?
The _____ which contains a set of pre-written networking java.net.packag
63 java.io java.awt None of these A
routines. e
java.net.UDPS java.net.Datagr
64 Which socket class can send packets unreliably? java.net.Socket None of these B
ocket amSocket
65 ____ class is used to create client in TCP/IP ServerSocket Server Calient None of these A
A ____ object is responsible for determining whether code
66 executing in the Java runtime environment has permission to Policy Security Both None of these A
perform a security-sensitive operation
What is default length of the queue in following constructor of
67 25 75 50 15 C
Servesocket serverSocket(int portno)
68 ____ is a bundle of information passed between machines. Datagram serversocket clientsocket None of these A
69 The ______ class is used to create TCP server. ServerSocket Server Calient None of these A
DatagramPacke
DatagramPacke DatagramPacke t(byte data[],int
70 select the proper constructor of DatagramPacket class? t(byte data[],int t(byte data[],int size,InetAddres All of above D
size) offset,int size) s ipAddress,int
port)
71 UDP protocol are knowing as ____ Datagram socket server None of these A
returns the socket and establish a connection between server public socket public void public void
72 None of these A
and client accept() wait() resume()
as a part of the
73 How to send data in get method? File Both None of these A
URL
Connection Connection
74 ___ class is used for accessing the attribute of a remote resource. Both None of these A
class oriented
what is the default length of the queue in following constructor of
75 50 75 100 180 A
Serversocket? ServerSocket(int portno)
which method of ServerSocket will wait for a client to
76 initiate communications and then communicate with the accept() wait() resume() None of these A
client
DatagramServe
77 The ___ class is used to create TCP server. ServerSocket Server Socket A
r()
DatagramSocke DatagramPacke DatagramClient DatagramServe
78 Which class is used to create UDP client? A
t() t() () r()
DatagramPacke DatagramSocke
79 Which of these classes is necessary to implement datagrams? Both None of these C
t t
Which of these methods of DatagramPacket is used to find the
80 port() getPort() findPort() receivePort() A
port number?
Which of these is a return type of getAddress method of DatagramPacke DatagramSocke
81 InetAddress ServerSocket C
DatagramPacket class? t t
ServerSocket(i Socket(InetAdd
82 Select the proper constructor of serversocket ntport, ressipAddress, Socket(int port) ServerSocket() A
intmaxQueue) intport)
Complete following server code for accepting client request.
Import java.io.*; import java.net.*; public class MyServer {
public static void main(String [] args) { try{ ServerSocket
Socket Socket
83 ss=new ServerSocket(6666); _____________ DataInputStream accept(); None of these B
sss.accept(); s=ss.accept();
dis=new DataInputStream(s.getInputStream()); String
str=(String)dis.readUTF();System.out.println("message="+str);ss.
close();}catch(Exception e){System.out.println(e);}}}
Which of these method of DatagramPacket is used to find the
84 getnumber() length() Length() getLength() D
length of byte array?
DatagramPacke DatagramSocke
85 Which of these class is necessary to implement datagrams? all none of these C
t t
Which of these method of DatagramPacket class is used to find getAddress()
86 findAddress() Address() whois() B
the destination address?
Which of these is a return type of getAddress method of DatagramPacke DatagramSocke
87 InetAddress ServerSocket C
DatagramPacket class? t t
Which of these methods is used to know when was the URL last getLastModifie GetLastModifie getlastModified
88 LastModified() B
modified? d() d() ()
Which of these methods is used to know the type of content getContentTyp GetContentTyp
89 ContentType() contentType() C
used in the URL? e() e()
DatagramSocke
Which constructor of DatagramSocket class is used to creates a DatagramSocke t(int port, DatagramSocke None of the
90 B
datagram socket and binds it with the given Port Number?​ t(int port) InetAddress t() above
address)
public
public
OutputStream public Socket
91 Which methods are commonly used in ServerSocket class?​ synchronized none of these B
getOutputStrea accept()
void close()
m()
Which class is used to create servers that listen for either local None of the
92 ServerSockets httpServer httpResponse A
client or remote client programs? above
The DatagramSocket and DatagramPacket classes are not used
93 TRUE FALSE B
for connection-less socket programming.​
Sr.No. Question Option A Option B Option C Option D Answer
Which of the following is used ResultSet
execute
1 generally for reading the content executeQuery execute() none of these A
update()
of the database? ()
ODBC
The JDBC-ODBC bridge allows JDBC drivers, Drivers, Application,
2 drivers, JDBC C
……….. to be used as ……….. ODBC drivers Application drivers
drivers
Native API converts JDBC calls, ODBC class,
ODBC class, JDBC calls,
3 ____________ into the network network A
user call user call
___________ used by DBMS. protocol protocol
Prepared statement object in
4 JDBC used to execute ____ executable simple high level parameterized D
queries.
5 JDBC-ODBC Bridge is multidynamic multithreaded both none of these B
The ____ method sets the query
6 parameters of the setString() setBoolean() setByte() setObject() A
PreparedStatement Object.
Prepared Statement
updatreemp=con.preparedStatem
ent("insert into emp
7 1 2 3 4 C
values(?,?,?)"); How many
values are need to iunsert for
PreparedStatement parameter?
Which JDBC driver Type(s) can
Both type 1 Both type 1 Both type 3
8 be used in either applet or servlet only Type 4 C
and 2 and 3 and 4
code?
Best for any All of the
9 JDBC-ODBC Bridge is multithreaded Three tiered A
platform above
ResultSet navigation method All of the
10 afterLast() beforeFirst() next() D
consist of above
Which of the following methods
Class.forNam registerDriver getConnection
11 are needed for loading a Both A and B C
e() () method ()
database driver in JDBC?
prepareStatement method is from PreparedState collableState
12 Both A and B none of these A
which class ment class ment class
_____ method of DriverManager
createConnect getConnection
13 class is used to establish with the both none of these B
ion() ()
database.
We can use ResultSet navigation
backward
14 methods when we have ResultSet Forward only both none of these A
only
that is of type
Which method is used for an
preparedState collableState
15 SQL statement that is executed statement() none of these A
ment ment()
frequently?
Which type of driver is unique in JDBC-ODBC JDBC-Native JDBC-Net 100% Pure
16 B
JDBC? bridge API pure Java Java
Which of the following method
preparedState collableState
17 is used to create object of statement() none of these A
ment() ment()
PreparedStatement interface
Which models does JDBC API
18 2Tier model 3 Tier model both none of these C
supports for database access?
select
TABLE_NA
ME from
INFORMATI
select * from
What is the query used to display ON_SCHEM
19 infromation_s both none of these B
all tables names in SQL Server? A.TABLES
chema,table
where
TABLE_TYP
E = 'BASE
TABLE'
Which statement is static and executeQuery executeUpdat getConnection
20 preparecall() C
synchronized in JDBC API () e() ()
executeBatch(
21 method returns the number of rowsexecuteUpdate() execute() executeQuery() A
)
The ____ method executes a
executeBatch(
22 simple query and returns a single executeUpdate() execute() executeQuery() D
)
Result Set object.
____ returns a
getColumnNa
23 ResultSetMetaData object getResultSet getMetaData getData C
me
describing the ResultSet.
___ method of DriverManager
getConnection acceptconnect establish
24 classes used to establish none of these A
() ion() connection()
connection with the database.
ResultSet navigation method
25 beforeFirst afterLast previous all D
consist of
The syntax for creating table create table create table
26 table course { table course( C
named course should begin with course { course(
Which method is used to retrive retriveResultS updateResultS
27 getResultSet() none of these B
the resultset created. et() et()
In JDBC ___ imports all Java
28 classes concerned with database javax.sql.* java.mysql.* java.sql.* com.* C
connectivity.
in MYSQL in MYSQL in MYSQL
Where is metadata stored in
29 database database database none of these C
MySQL?
metadata metasql mysql
MY-SQL stored data in ___ file
30 .DAT .MDB .MSSQL .OBJ A
format
ODBC
The JDBC-ODBC bridge allows JDBC drivers, Drivers, Application,
31 drivers, JDBC C
____ to be used as ____ ODBC drivers Application drivers
drivers
For execution of DELETE SQL
executeQuery executeDelete executeUpdat executeDelete
32 query in JDBC, ___ method must C
() Query() e() ()
be used.
executeQuery() method ResultSet Single Database
33 Single row B
returns_____________________ object Column Table
PreparedStatement interface
34 extends____________________ Connection Statement ResultSet Driver B
interface
executeUpdate() method ResultSet
35 Single row Integer Single column C
returns_____________________ object
Standard Sequential Structured Server side
36 ____ is a full form of SQL query query query query C
language language language language
To select all column from the select all from select * from select from
37 none of these B
table the syntax is table name table name table name
How many JDBC driver types
38 One Two Three Four D
does sun define?
Which JDBC driver Type(s) is
39 Type 1 Type 2 Type 3 Type4 A
(are) the JDBC-ODBC bridge?
A Java program cannot directly ODBC written ODBC written ODBC written
ODBC written
40 communicate with an ODBC in C# in C++ in Basic D
in C language
driver because ....... language language language
The JDBC-ODBC Bridge driver
41 translates the JDBC API to the JDBC drivers ODBC drivers Both none of these B
ODBC API and used with .......
. The
................................method executeUpdat executeDelete
42 execute() nonexecute() B
executes a simple query and e() Query()
returns a single Result Set object
State true or false. Is the
43 JDBC-ODBC bridge is TRUE FALSE A
Multithreaded?
Which of the following type of JDBC-ODBC
Native-API, JDBC-Net, Native-protoc
JDBC driver, uses database Bridge plus
44 partly Java pure Java ol, pure Java D
native ODBC
driver driver driver
protocol? driver
Which of the following type of JDBC-ODBC
Native-API, JDBC-Net, Native-protoc
JDBC driver, is also called Type Bridge plus
45 partly Java pure Java ol, pure Java B
2 JDBC ODBC
driver driver driver
driver? driver
A JDBC
RowSet object
holds tabular
data in a way A RowSet
Which of the following is correct that makes it objects are Both of the
46 none of these C
about RowSet? more JavaBeans above.
flexible and components.
easier to use
than a result
set.
Select the class or interface
Driver Driver ResultSet Connection
47 which is not used for database B
Manager interface interface interface
connectivity
1. Consider the following
program.
What should be the correction
done in the program to get
correct output?
import java.sql.*;
class Ddemo1
{
public static void main(String
args[]) throws Exception
{
Class.forName("sun.jdbc.odbc.Jd
bcOdbcDriver");
Connection
c=DriverManager.getConnection
Missing Missing
48 ("jdbc:odbc:ODSN"," "," "); Missing { Missing } C
semicolon statement
Statement s=c.createStatement();
ResultSet
rs=s.executeQuery("select *from
StudTable");
System .out.println("Name" + " \t
" + "Roll_No" + " \t " + "Avg");
while(rs.next())
{
System.out.println(rs.getString(1
)+" \t "+rs.getInt(2)+" \t
\t"+rs.getDouble(3));
s.close();
c.close();
}}
1. Consider the following
program.
What should be the correction
done in the program to get
correct output?
import java.sql.*;
class Ddemo1
{
{
Class.forName("sun.jdbc.odbc.Jd
bcOdbcDriver");
Connection
c=DriverManager.getConnection
("jdbc:odbc:ODSN"," "," ");
Statement s=c.createStatement();
Missing Missing
49 ResultSet Missing { Missing } D
semicolon statement
rs=s.executeQuery("select *from
StudTable");
System .out.println("Name" + " \t
" + "Roll_No" + " \t " + "Avg");
while(rs.next())
{
System.out.println(rs.getString(1
)+" \t "+rs.getInt(2)+" \t
\t"+rs.getDouble(3));
}
s.close();
c.close();
}
}
1. Consider the following
program.
What should be the correction
done in the program to get
correct output?
import java.sql.*;
class Ddemo1
{
public static void main(String
args[]) throws Exception;
{
Class.forName("sun.jdbc.odbc.Jd
bcOdbcDriver");
Connection
c=DriverManager.getConnection Error in
Error in Error in
50 ("jdbc:odbc:ODSN"," "," "); Error in loop connection A
main() close()
Statement s=c.createStatement(); statement
ResultSet
rs=s.executeQuery("select *from
StudTable");
System .out.println("Name" + " \t
" + "Roll_No" + " \t " + "Avg");
while(rs.next())
{
System.out.println(rs.getString(1
)+" \t "+rs.getInt(2)+" \t
\t"+rs.getDouble(3));
}
s.close();
c.close();}}
1. Consider the following
program.
What should be the correction
done in the program to get
correct output?
class Ddemo1
{
public static void main(String
args[]) throws Exception
{
Class.forName("sun.jdbc.odbc.Jd
bcOdbcDriver");
Connection
c=DriverManager.getConnection
("jdbc:odbc:ODSN"," "," "); Missing
Missing
51 Statement s=c.createStatement(); Missing { Missing } packagestate D
semicolon
ResultSet ment
rs=s.executeQuery("select *from
StudTable");
System .out.println("Name" + " \t
" + "Roll_No" + " \t " + "Avg");
while(rs.next())
{
System.out.println(rs.getString(1
)+" \t "+rs.getInt(2)+" \t
\t"+rs.getDouble(3));
}
s.close();
c.close();
}}
Consider the following program
Select the statement that should
be added to the program to get
correct output.
import java.sql.*;
public class db15
{public static void main(String
args[])throws Exception
{Class.forName("sun.jdbc.odbc.J
dbcOdbcDriver");
Connection c
=DriverManager.getConnection("
jdbc:odbc:MyDSN","","");
PreparedStatement
s=c.prepareStatement( "update
db3 set Name=? where
c.createStatem
52 Roll_no=?"); s.executeUpda s.close() c.close() A
ent( )
Statement s=c.createStatement( ); te()
s.setString(1,args[0]);
s.setString(2,args[1]);
s.setString(3,args[2]);
ResultSet
rs=s.executeQuery("select* from
db3");
System.out.println("Name"+"\t"+
"Roll no"+"\t"+"Avg");
while(rs.next())
{System.out.println(rs.getString(
1)+"\t"+rs.getInt(2)+"\t"+rs.getD
ouble(3));}
s.close();
c.close();}}
2. Consider the following
program
import java.sql.*;
public class db15
{
public static void main(String
args[])throws Exception
{
Class.forName("sun.jdbc.odbc.
JdbcOdbcDriver");
Connection c
=DriverManager.getConnectio
n("jdbc:odbc:MyDSN","","");
PreparedStatement
s=c.prepareStatement( "update
db3 set Name=? where
Roll_no=?");
Statement s=c.createStatement(
);
s.setString(1,*);
s.setString(2,*);
A. Command
53 s.setString(3,*); B. Array C. Vector D. Integer A
line argument
s.executeUpdate();

ResultSet
rs=s.executeQuery("select*
from db3");
System.out.println("Name"+"\
t"+"Roll no"+"\t"+"Avg");
while(rs.next())
{
System.out.println(rs.getString
(1)+"\t"+rs.getInt(2)+"\t"+rs.g
etDouble(3));
}
s.close();
c.close();
}
}
Option Option Option Option
Sr.No. Question A B C D Answer
< @ %= none of
JSP starts and end with symbol <% %> <%= %>
1 %> these A
both a and none of
A JSP page consists of which tags? HTML JSP
2 b these C
getRequest
Which method of HTTPServeltResponse is used to redirect an redirectUR sendRedirc redirctHttp
Dispatcher(
HTTP request to another URL L() t() ()
3 ) B
Non-Persis
Which cookies it is valid for single Session only, it is removed Persistent both a and none of
tent
each time when user closes the browser? Cookies b these
4 Cookies A
In order to create a HTTPServelet following import
statements are used:- a.import java.io.*; a,b,c are only a and only a and
only a
b.import javax.servlet.* c.import compulsary c b
5 javax.servlet.http.*; A
getServlet none of
Which is not method of GenericServlet class destroy() init()
6 Config() these D
Platform
both a and none of
Servlet is __________ interface independen
b these
7 t C
Which of the following is the deployment descriptor file in none of
web.xml web.html web.java
8 servlet these A
javax.servl javax.Servl
In servlet programming a cookies is respresented by the javax.servl javax.servl
et.http.coo et.http.coo
cookie class in ____ package et.cookie et.cookie
9 kie kie B
startapache none of
Which file will start tomcat server? startup.txt start.bat
10 .bat these B
javax.servl
javax.servl
et.servletC both a and none of
init(), service(), destroy() method are declared in ____ et.Servlet
onfig b these
interface
11 interface A
state
informatio Client Server Program
A cookie contains___ n of userr Informatio Informatio Informatio
like name, n n n
12 address A
enumeratio
n of all the an object
parameter the name
The getInitParameter() method of ServletConfig interface initializatio of
passes to of the
returns _____ n ServletCon
the servlet servlet.
parameter text.
13 names. A
The session
The session The session object is
getSession() method with true as parameter it will return the The session
is does not passed to
appropriate session object is existing
completed exists another
14 method D
none of
_____ is destructive phase of JSP life cycle. cleanup Service() destroy()
15 these A
CGI is not
CGI is
platform
platform
independen
independen
t but
Servlet offer following advantages over CGI t but
servlet are
servlet are
platform
platform
independen
depended
16 t A
Tag library tag library both a and none of
TLD stands for _____
17 descriptor Data b these A
what is the limit of the data to be passed from HTML when
2kb 3kb 4kb 5kb
18 doGet() is used? A
Which mechanism is included by jsp for defining custom static local dynamic global
19 tags? attributes attributes attributes attributes C
PUT FTP WRITE COPY
Name the http method used to send resources to the server
20 Method Method Method Method A
The ___ method is called when servlet is First created and not
init() service() destroy() all of these
21 called again A
Servlet, HTML, HTML, Java,
JSP embeds in ____ in ____
22 HTML Java Servlet HTML C
23 Servlet life cycle have ____ state 2 3 4 5 B
appends
Sends a
includes the request
request to
resource of and
another none of
The inculde() method of RequestDispatche file like response
resource these
servlet, jso objects to
like servlet
or html the current
,jsp or html
24 servlet A
jspService( jspDestroy( none of
JSP page performs request processing by calling ___ method. JspInit()
25 ) ) these B
The following methods belongs to life cycle methods of
init() Service() destroy() all of these
26 servlet D
getSession( GetSession getsessionI none of
______ method gives the current session
27 ) () D() these A
ServletReq ServletReq ServletCon
Suppose you want to know each time request comes in, so HttpReque
uestListene uestAttribu textListene
that you can log it.Which listener is appropriate for that? stListener
28 r teListener r A
Which class provides stream to read binary data such as ServltInput ServletOut both a and none of
29 image etc. from the request object? Stream putStream b these A
ServletReq ServletCon HttpSessio
If you want to track active session or how many users are HttpSessio
uestListene textListene nBindingLi
there ? Which listener you should use. nListener
30 r r stener C
Disadvantage of CGI: 1.It has lack of scability abnd reduced
1 and 2 1 and 3 only 3 all of these
31 speed. 2.High performance time 3.CGI is platform dependent B
Java Java Either 1 or
A JSP is transformed into a(n): None
32 Applet Servlet 2 B
The Java __________ specification defines an application
programming interface for communication between the Web Servlet Server Program Randomize
33 server and the application program. A
What programming language(s) or scripting language(s) does VBScript
Jscript only Java only All
34 Java Server Pages (JSP) support? Only C
35 ___ are JSP code fragments embedded within <%...%> tags. Scriptlets Servlet Cookie all A
request.get request.set responce.g responce.g A
The doGet() method in the example extracts values of the
Parameter( Parameter( etParamete etAttribute(
parameter’s type and number by using __________
36 ) ) r() )
web web B
web
component component
A deployment descriptor describes component all
response request
settings
37 settings objects
Name the class that includes the getSession() method that is HttpServlet HttpServlet SessionCo SessionCo A
38 used to get the HttpSession object Request Response ntext nfig
A user types the URL http://www.msbte.com/result.php. A
GET POST HEAD PUT
Which HTTP request gets generated. Select the one correct
method method method method
39 answer
A session A
refers to
the entire
interaction
between
A session A session
client and A session
is a time refers to
What is session in Servlet programming? server from is a
taken by time taken
the time of interaction
server by client
client
logon to
logout
from
40 system
Open Open go to A
Write
Notepad, Notepad, explorer
HTML
Write Save file and write
code, Save
HTML with command
file with
code, Save extension http://locati
extension
file with .html, go to on:8080/cr
.html, go to
extension explorer eated
explorer
.html, go to and write folder
Find correct Steps for creating and executing HTML file for and write
explorer command name/*.ht
Servlet programming command
and write http://locati ml, Open
http://locati
command on:8080/cr Notepad,
on:8080/cr
http://locati eated Write
eated
on:8080/cr folder HTML
folder
eated name/*.ht code, Save
name/*.ht
folder ml, Write file with
ml, open
name/*.ht HTML extension
notepad
41 ml code .html
Browser C
Browser Browser
will
will Browser will
What is meaning of following statement interpret
interpret will take interpret
Res.setContentType(“text/html”); content as
content as contents as content as
HTML
source plain text Java source
source
code. code.
42 code.
void void void void A
service(Ser service( service(Ser service(Ser
vletReques ServletRes vletReques vletRespon
Identify correct syntax of service() method of servlet class
t req, ponse res t req, se req,
ServletRes ServletReq ServletReq ServletRes
43 ponse res) uest req, ) uest req ) ponse res)
Choose missing statements in following code from given
options.
Program for session
// program for session
public class session1 extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException {
// Get the HttpSession object.
import
HttpSession hs = request.getSession(true); import import
java.io.*; import
// Get writer. javax.servl javax.servl
import java.Vector
response.setContentType("text/html"); et.http.*; et.http.*;
java.util.*; .* ; import
PrintWriter pw = response.getWriter(); import import
import java.Threa
pw.print("<B>"); java.Threa java.String.
javax.servl d.*; import
// Display date/time of last access. d.*; import *; import
et.*; import javax.servl
Date date = (Date)hs.getAttribute("date"); javax.Clien java.Vector
javax.servl et.*;
if(date != null) { t.*; ;
et.http.*;
pw.print("Last access: " + date + "<br>");
}
// Display current date/time.
date = new Date();
hs.setAttribute("date", date);
pw.println("Current date: " + date);
}
}
44 B
. In following Java program fill statement showing ***.Select
any one option fro given options
Program for cookie
// program for cookie
import javax.servlet.*;
import javax.servlet.http.*;
public class AddCookieServlet extends HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException {
// Get parameter from HTTP request.
new new new new
String data = request.getParameter("data");
Cookie("M Cookie("M Cookie("M Cookie("M
// Create cookie.
yCookie", yCookie", yCookie", yCookie",
Cookie cookie = ***************
data); data1); data2); database);
// Add cookie to HTTP response.
response.addCookie(cookie);
// Write output to browser.
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>MyCookie has been set to");
pw.println(data);
pw.close();
}
}
45 A

You might also like