AJP MCQ Bank 1ALLCH
AJP MCQ Bank 1ALLCH
Q. 2 Which is the container that contain title bar and can have MenuBars. It can have other components
like button, textfield etc.?
(a) Panel (b) Frame
(c) Window (d) Container
Answer: b
D. 3 Which is a component in AWT that can contain another components like buttons, textfields, labels etc.?
(a) Window (b) Container
(c) Panel (d) Frame
Answer:b
Page 1 of 58
Q. S Which class provides many methods for graphics programming?
(a) java.awt
(b) java.Graphics
(c) java.awt.Graphics
(d) None of the
aboveAnswer:c
Q. 6 These two ways are used to create a Frame By creating the object of Frame class (association) By
extending Frame class (inheritance)
(a) True
(b) False
Answer:a
Q.7 Which is the container that doesn't contain titlebar and MenuBars. It can have other components like button,
textfield etc?
(a) Window
(b) Frame
(c) Panel
(d) Container
Answer:c
Q. 8 How many types of controls does AWT supports these controls are subclasses of component?
(a) 7
(b) 6
(c) 5
(d) 8
Answer:a
D. 9 Which are passive controls that do not support any interaction with the user?
(a) Choice
(b) List
(c) Labels
(d) Checkbox
Answer:c
Q. 11 Which class is used to create a pop-up list of items from which the user may choose?
(a) List
(b) Choice
(c) Labels
(d) Checkbox
Answer:b
Page 2 of 58
D. 12 Which object can be constructed to show any number of choices in the visible window?
(a) Labels
(b) Choice
(c) List
(d) Checkbox
Answer:c
D. 13 Which is used to store data and partial results, as well as to perform dynamic linking, return valuesfor
methods, and dispatch exceptions?
(a) Window
(b) Panel
(c) Frame
(d) Container
Answer:c
Q. 14 The following way is used to create a frame is by creating the object of Frame class?
(a) inheritance
(b) association
(c) Both A 8 B
(d) None of the above
Answer: c
Q. 15 AWT more powerful components like tables, lists, scroll panes, color chooser, tabbed pane etc.?
(a) True
(b) False
Answer: a
Q. 17 In Graphics class which method is used to draws a rectangle with the specified width and height?
(a) public void drawRect(int x, int y, int width, int height)
(b) public abstract void fiIIRect(int x, int y, int width, int height)
(c) public abstract void drawLine(int x1, int y1, int x2, int y2)
(d) public abstract void draw0vaI(int x, int y, int width, int height)
Answer: b
Q. 18 Implement the Listener interface and overrides its methods is required to perform in event handling?
(a) True
(b) False
Answer: a
Page 3 of 58
Q. 19 Public class MenuBar extends
(a) MenuComponent
(b) MenuContainer
(c) ComponentMenu
(d) MenuBa
rAnswer: a
Q. 20. Which of the following is true about AWT and Swing components?
(a) AWT components creates a process where as swing components creates a thread
(b) AWT components creates a thread whereas swing components creates a process
(c) Both AWT and Swing components creates a process
(d) Both AWT and swing components creates a thread
Answer: c
Q. 21 Panel is defined as
(a) The Panel class is a concrete subclass of Container.
(b) A Panel is a window that does not contain titlebar, menubar and border.
(c) Panel is a superclass of Applet.
(d) All of the above.
Answer: d
Page 4 of 58
Q. 26 Which is the correct constructor of GridLayout.
(a) GridLayout(int a)
(b) GridLayout(int num rows, int num columns)
(c) GridLayout(int rows, int cols, int vert)
(d) GridLayout(int
hor)Answer: b
Q. 28 In the give constructor what third parameter indicates : ScrollBar s = new ScrollBar(0,10,20,0,1000);
(a) size of thumb
(b) minimum value
(c) Increment value
(d) Initial
ValueAnswer:
a
Q. 29 Which class is used to represent a single line textbox with password character facility?
(a) TextField
(b) TextArea
(c) Label
(d) Checkbox
Answer: a
Q. 31 Suppose a Panel is added to a Frame and a Button is added to the Panel. If the Frame‟s font is set
to 12 point Times New Roman, the panel‟s font is set 10 points Times New Roman and the Button's
font is not set. What font will be used to display the Button's label?
(a) 12 point Times New Roman
(b) 11 point Times New Roman
(c) 10 point Times New Roman
(d) 9 point Times New Roman
Answer: c
Page 5 of 58
(d) Both A &
B.
Answer: d
Q. 34 positions are the components into 5 regions east, west, south, north, center.
(a) CardLayout
(b) BorderLayout
(c) GridLayout
(d) FlowLayout
Answer: b
D. 35 What is API?
(a) Application Programming Interchange
(b) Application Programming Interaction
(c) Application Programming Interface
(d) None of these
Answer: c
D. 36 Panel is defined as
(a) Panel class is a concrete sub-class of container
(b) A Panel is a window that does not contain a title bar, menu bar or border
(c) Panel is the superclass of Applet
(d) All of above
Answer: d
D. 38 When there is a switching condition like ON or OFF, which control is used of following?
(a) Button
(b) RadioButton
(c) ToggleButton
(d) TextField
Answer: c
Page 6 of 58
Q. 40 The getContentPane( ) method is of which class?
(a) JApplet
(b) JFrame
(c) JButton
(d) None of these
Answer: d
Q. 43 Which Text Component method is used to set a TextComponent to the read-only state?
(a) Editable
(b) NonEditable
(c) setEchoChar
(d) setEditable
Answer:d
Q. 44 How would you set the color of graphics context called g to cyan?
(a) g.setCoIor(“cyan”);
(b) g.setCurrentCoIor(cyan);
(c) g.setCoIor(“Color.cyan”);
(d) g.setCoIor(Color.cyan);
Answer: d
Q. 46 The setBackground() method is part of which of the following class java.awt package?
(a) Component
(b) Applet
(c) Object
(d) Graphics
Answer: a
Page 7 of 58
Q. 47 What does the following line of code do? TextField If = new TextFieId(10);
(a) will set 10 to TextField as its initial text.
(b) Will set the character capacity to 10
(c) Both A & B
(d) None of These
Answer: b
Page 8 of 58
Q. 54 Which of the following does not have its default layout as BorderLayout.
(a) Frame
(b) Dialog
(c) JApplet
(d) All of
Above
Answer: d
Page 9 of 58
Q. 61 Which of these Components cannot be added to Frame?
(a) Label
(b) Button
(c) CheckboxGroup
(d) All of above
Answer: c
Q. 63 Which of these classes can be added to any Container class, using the add method definedin
Container class?
(a) Button
(b) CheckboxMenultem
(c) Menu
(d) MenuBar
Answer: a
Page 10 of 58
Q. 67 The default layout of Applet is
(a) GridLayout
(b) CardLayout
(c) FlowLayout
(d) BorderLayout
Answer: c
Q. 70. Which of the following is a valid HTML file to run an applet program store in
MyApplet.java file?
a) <APPLET CODE = "MyAppIet.cIass"></APPLET>
b) <APPLET C0DE="MyAppIet.java" WIDTH=250 HEIGHT=200>
c) <appIet code="MyAppIet.class" width=250 height=200></appIet>
d) <appIet code="MyAppIet” height =”250” width
=”200"></appIet>Answer: c
Q. 71. Which of the following sets the frame, say frame to 300 pixels wide by 200 high?
a) frame.setsize( 300, 200 );
b) frame.setSize( 300, 200 );
c) frame.paint( 300, 200
); d)frame.setVisible(
300, 200); Answer: a
Page 11 of 58
Q. 72. Fill in the blanks so that this program displays a Frame:
java.awt.*;
public class
microGUl
Q. 73. What is the length of the application box made by this program?
import
java.awt.*;
import
java.applet.*;
public class myapplet extends
Applet ( public void
paint(Graphics g) (
g.drawString("A Simple Applet", 20, 20);
a) 20
b) 5
0
1
0
0
d)System Dependent
Answer: a
Page 12 of 58
Q. 74.Which components are used in the following output?
Page 13 of 58
02 - Swings Marks:-10
Content of Chapter:-
2.1 Introduction to Swing: Swing features, Difference between AWT and Swing.
2.2 Swing Components: JApplet, Icons and Labels, TextFields
2.3 Buttons: JButton, CheckBoxes, Radio Buttons.
2.4 Advance Swing Components: Tabbed Panes, Scroll Panes, Tress, Tables, Progress Bar, Tool Tips.
2.5 MVC Architecture.
Q. 2 Swing is not a part of JFC (Java Foundation Classes) that is used to create GUI application?
(a) True (b) False
Answer:b
Q. 3 The Swing Component classes that are used in Encapsulates a mutually exclusive set of buttons?
(a) AbstractButton
(b) ButtonGroup
(c) JButton
(d) Imagelcon
Answer: b
Q. 4 The Java Foundation Classes (JF(c) is a set of GUI components which simplify thedevelopment of desktop applications?
(a) True (b) False
Answer: a
Page 14 of 58
Q. 6 The String parameter to JButton constructor
(a) tell which region to put the JButton in.
(b) tells the color of the JButton.
(c) tells what text will appear on JButton.
(d) tells what should happen when JButton is pressed.
Answer: c
Page 15 of 58
Q. 13 class used to create node in tree.
(a) TreeNode
(b) DefaultMutableNode
(c) DefaultMutableTreeNode
(d) Node
Answer: c
Page 16 of 58
Q. 20. How will you set icon for the Jlabel?
a) Using Icon class directly
b) Using setlcon( ) method
c) Using makelcon( ) method
d) It is not possible to set icon for
JLabelAnswer: b
Q. 25. The scroll bar constants for scroll pane are defined in
a) Scrollbar class
b) ScrollPane class
c) ScrollPaneConstants interface
d) Component class
Answer: c
Page 17 of 58
Q. 27. Is it possible to add array of objects to trees? How?
a) Not possible
b) Yes, using its one of the forms of constructor
c) Yes, using the add( ) method
d) Yes, using the addltem( ) method
Answer: b
javax.swing.JFrame;import
javax.swing.JTree;
importjavax.swing.SwingUtilities;
javax.swing.tree.DefaultMutableTreeNode;
public class TreeExample extends JApplet
(JTree
tree; public
voidinit() (
DefaultMutableTreeNode root = new DefauItMutabIeTreeNode("Root");
DefaultMutableTreeNode vegetableNode = new
DefauItMutabIeTreeNode("Vegetables"); DefaultMutableTreeNode fruitNode =new
DefauItMutabIeTreeNode(”Fruits"); root.add(vegetableNode); root.add(fruit
Node); tree =
new JTree();
add(tree);
javax.swing.*;
public class Combo extends JApplet(
public void init() (
Container c=getContentPane();
JComboBoxjc=new JComboBox();
jc.addItem("AJP”);
jc.addItem("
STE")
jc.addItem("AMI”); jc.addItem("EDP”);
Page 18 of 58
/*<appIet code="Combo.class" height=200 width=200></appIet>*/
a) Add(jc);
b) Jc.add(c);
c) c.add(jc);
d) Add(c);
Answer: c
Q. 32. Which two parameters are required for JTree constructor to create a tree?
a) Data array and Row Headings
b) Data array and Column Headings
c) Single data element and Column heading
d) Single data element and Row heading
Answer: b
Page 19 of 58
03 - Event Handling Marks:-12
Content of Chapter:-
3.1 The delegation Event Model, Event sources, Event listeners
3.2 Event classes: The Action Event class, the Item Event class, the Key Event class, the Text Event class,the
Window Event class.
3.3 Adapter classes
3.4 Inner classes
3.5 Event listener interfaces: The ActionListener Interface, the ItemListener Interface, the KeyListener
interface, the MouseListener interface, the MouseMotion interface, the TextListener interface, the
WindowsListener Interface.
Q. 1. The Following steps are required to perform Implement the Listener interface and overridesits
methods Register the component with the Listener
(a) Exception Handling
(b) String Handling
(c) Event Handling
(d) None of the above
Answer: c
Q. 3 Which package provides many event classes and Listener interfaces for event handling?
(a) java.awt
(b) java.awt.Graphics
(c) java.aM.event
(d) None of the above
Answer: c
Q. 4 To use the ActionListener interface it must be implemented by a class there are several ways to do that
find in the following?
(a) Creating a new class
(b) using the class the graphical component
(c) an anonymous inner class
(d) All mentioned above
Answer: d
Page 20 of 58
Q. 6 The ActionListener interface is used for handling action events, For example, it's used by a
(a) JButton
(b) JCheckbox
(c) All of these
(d) JMenultem
Answer: c
Q. 8 In Graphics class Which method is used to set the graphics current color to the specified color?
(a) public abstract void setFont(Font font)
(b) public abstract void setCoIor(Color c)
(c) public abstract void drawString(String str, int x, int y)
(d) None of the above
Answer: b
Q. 9 Which of the following method is used to determine the type of adjustment event?
(a) getType( )
(b) getEventType( )
(c) getAdjustmentType( )
(d) getEvent0bjectType( )
Answer: c
Page 21 of 58
Q. 13 The signature for the registration method for a ActionEvent should be
(a) public void addActionListener(ActionEvent L)
(b) public void setAction(ActionListener L)
(c) public void setActionListener(ActionListener L)
(d) public void addActionListener(ActionListener L)
Answer: d
Q. 16 Name the method defined in Event0bject class that returns the object generated from the event.
(a) getEvent( )
(b) get0bject( )
(c) getld( )
(d) getsource( )
Answer: d
Q. 18 ActionEvent is applied on
(a) Frame
(b) Checkbox, Choice, List
(c) Scrollbar
(d) Button, TextField, List, Menu
Answer: d
Page 22 of 58
Q. 20 If we close an applet window events will be generated.
(a) ActionEvent
(b) ComponentEvent
(c) AdjustmentEvent
(d) WindowEvent
Answer: d
Q. 25 When we need to use Checkbox or Item from the list or use a checkable Menu an is generated.
(a) ActionEvent
(b) ItemEvent
(c) MenuEvent
(d) ClickEvent
Answer: b
Page 23 of 58
Q. 27 Which of the following is not the method of handling window event?
(a) void windowCIosed(WindowEvent we)
(b) void windowCIosing(WindowEvent we)
(c) void windowAfterCIosing(WindowEvent we)
(d) All of these
Answer: c
Q. 30 Which of this package contains all the classes and methods required for event handling in Java.
(a) java.applet
(b) java.awt
(c) java.event
(d) java.awt.event
Answer: d
Q. 31 Name the method defined in Even0bject class that returns the object generated from the event.
(a) getEvent( )
(b) get0bject( )
(c) getld( )
(d) getsource( )
Answer: d
Page 24 of 58
Q. 34 Clicking the closing button on the upper right corner of a frame generates a (n)-event.
(a) ItemEvent
(b) WindowEvent
(c) MouseMotionEvent
(d) ComponentEvent
Answer: b
Q. 35 Which of the following method must be overridden in the order to handle KeyEvent.
(a) keyPressed(KeyEvent obj)
(b) KeyReIeased(KeyEvent obj)
(c) KeyTyped(KeyEvent obj)
(d) All of these
Answer: d
Q. 36 Which of these methods can be used to know the degree of adjustment made by the user?
(a) getValue( )
(b) getAdjustmentType( )
(c) getAdjustmentValue( )
(d) getAdjustmentAmount( )
Answer: c
Page 25 of 58
String msg = ;
intmouseX = 0,
mouseY = Opublic
void init()
mouseX=0;
mouseY = 10;
msg =
"Mouse
clicked.";re
paint();
mouseX=0;
mouseY
= 10;
msg =
"Mouse
entered.";repaint();
mouseX=0;
mouseY = 10;
msg =
"Mouse
exited.*,rep
aint();
=
me.getX();mouseY
me.getY();m sg =
"Down*,
repaint();
=
me.getX();mo
useY
me.getY();m
sg = "Up”;repaint();
Page 26 of 58
public void mouseDragged(MouseEvent me)
mouseX =
me.getX();mouseY
me.getY();ms
void paint(Graphics g)
a) addMouseMotionListener(this);
Ł) addMouseListener(this);
c) import java.awt.event.*;
ü) all of above
Page 27 of 58
Q. 41. Select the proper output for followingcode
Importjava.awt.*;
import java.applet.*;
public class Iist2 extends Applet
List I= new
List(2,true);
I.add("java"
)'
I.add("c++");
I.add("kkk"); add(I);
b)
c)
d)
Page 28 of 58
D. 42. To get the following output complete the code given below.
init()(
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
Page 29 of 62
D. 43. Select proper code for given output
A.
importjava.aM.*; importjava.applet.*; public class
choicell extends Applet
B.
importjava.awt.*; importjava.applet.*; public
class choicell extends Applet
c.
importjava.awt.*; importjava.applet.*; public
class choicell extends Applet
Page 30 of 62
os.add("wnn18");
os.add(”wnnxp”);
os.add(”wnnnt”);
os.add("win 2000");
add(os);
D.
importjava.awt.*; importjava.applet.*;
public class choicell extends Applet
D. 44. Select the missing statement in the program to get the following output
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
JLabel jl;
Image Iconfrance, germany, italy, japan;
public void init()(
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
JComboBoxjc = new JComboBox();
Page 31 of 62
jc.addItem(”France”); jc.addItem(”Germany");
jc.addItem(”Italy"); jc.addItem(”Japan");
jc.addItemListener(this); contentPane.add§c);
contentPane.add§I);
String s = (String)ie.getltem();
jI.setIcon(new Imagelcon(s +
".gif'));
Q. 45. Select the missing statement in the program for following output
import java.aM.*;
public class MenuDemo extends Framepublic
A. mbr.add(view);
B. mbr.add(menu);
Page 32 of 62
C. mbr.add(vieweditmenu);
D. mbr.add(viewmenu);
0.46. Consider the following output. Find the missing statement in the program.
importjava.awt.*; import
java.aM.event.*;
importjava.applet.*;
importjavax.swing.*;
addKeyListener(this);
requestFocus();
showStatus(”Key Down");
showStatus(”Key Up");
public void keyTyped(KeyEvent ke)
msg +=
ke.getKeyChar();
repaint();
a) Missing Semicolon
b) }
c) (
Page 33 of 62
d) ()
Q.47. For the following code select the method that can be used to handle event.
importjava.awt.event.*;
import java.aM.*;
importjava.applet.*;
public class checkbackg extends Applet implements ItemListener
Checkbox m1,m2,m3;
public void init()
m1=new Checkbox("A");
m2=new Checkbox("B");
m3=new
Checkbox("C");
add(m1);
add(m2);
add(m3);
m1.addItemListener(this);
m2.addItemListener(this);
if(ie.getSource()==m1)
setBackground(Color.red);
if(ie.getSource()==m2)
setBackground(Color.green);
a) actionPerformed(ActionEvent ae)
b) itemStateChanged(ActionEvent ie)
c) itemStateChanged(ItemEvent ie)
d) adjustmentPerformed(AdjustmentEvent ae)
Page 34 of 62
04 - Networking Basics Marks:-10
Content of Chapter:-
4.1 Basics of Networking Socket Overview: CIient/ Servers, Internet Addressing. Event classes: The ActionEvent class, the Item Event class, the
Key Event class, the Text Event class, the Window Event class.
4.2 Java and the Net: The Networking Classes and Interfaces Inner classes
4.3 InetAddress: Factory Methods, Instance Methods
4.4 TCP/IP Client Sockets: Whois
4.5 URL: Format, The Url Class
4.6 URLConnection: TCP/IP Server Sockets
4.7 Datagrams:DatagramPacket, Datagram Server and Client
Q. 2 Name the class which is used to create a port where the server will listen.
(a) Server
(b) Socket
(c) ServerSocket
(d) SocketServer
Answer: b
Page 35 of 62
(b) 4tier
(c) n - tier
(d) all of the above
Answer: d
Page 36 of 62
Q. 12 The class which encapsulates both the numerical IP address and the domain name for that address
ÏS
(a) DatagramPacket
(b) DatagramSocket
(c) InetAddress
(d) ServerSocket
Answer: c
Q. 14 In this constructor ServerSocket(int port, int max queue) what is the default value for max queue?
(a) 100
(b) 50
(c) 75
(d) 80
Answer: b
Page 37 of 62
Answer: a
Q. 19 What value is returned by the readLine( ) method when it reach at End of File?
(a) EOF
(b) null
(c) 0
(d) END
Answer: b
D. 21 Which method of ServerSocket will wait for a client to initiate communication and then communication with
the client?
(a) wait( )
(b) connect( )
(c) waitForClient( )
(d) WaitForConnect( )
Answer: b
Q. 25 Which of these method of DatagramPacket class is used to find the destination address?
(a) findAddress( )
(b) getAddress( )
(c) address( )
(d) whols( )
Answer: b
Page 38 of 62
Q. 26 Connection oriented communication is possible using classes of Java.
(a) Socket and ServerSocket
(b) DatagramSocket and DatagramPacket
(c) Both of these
(d) None of these
Answer: c
Q. 29 If a program consists of three classes, then after compilation how many class files will be created by the
compiler?
(a) one
(b) three
(c) uncountable
(d) zero
Answer: b
Page 39 of 62
D. 33 Which class defines following methods?int
getContentLength( )
long getDate( )
long getExpiration( )
(a) URLConnection
(b) Datagram
(c) Client
(d) None of these
Answer: a
D. 34 Name the class which is used to create a port where the server will listen?
(a) Server
(b) Socket
(c) ServerSocket
(d) SocketServer
Answer: b
Q. 37 Which is the proper method to retrieve the host name of local machine?
(a) static InetAddress getLocalHost( ) throws UnknownHostException
(b) static InetAddress getByName(String host name ) throws UnknownHostException
(c) static InetAddress getAIIByName(String host name ) throws UnknownHostException
(d) String getHostAddress( )
Answer: a
Page 40 of 62
D.39. What will be displayed in the output?importjava.net.*;
classmyAddress
tv
InetAddress address = InetAddress.getLocaIHost(); System.out.printIn(address);catch
(UnknownHostException e)
Page 41 of 62
Q.41. Consider the following program
What correction should be done in the program to get correct output?
importjava.net.*; importjava.io.*;
public class URLTest
Page 42 of 62
05 - Interacting with Database Marks:-12
Content of Chapter:-
5.1 Introduction to JDBC:ODBC
5.2 JDBC Architecture: Two and Three Tier models
5.3 Types of JDBC Drivers
5.4 Driver interface, Driver Manager class, Connection Interface, Statement Interface, the
java.sql.package Establishing connection 8 retrieving information Resultset
5.5 The Essential JDBC Program.
Q. 1 The package contains classes that help in connecting to a database, sending SQL
statements to the database and process the query request.
(a) connection.sql
(b) db.sql
(c) pkg.sql
(d) java.sql
Answer: a
Q. 3 In JDBC imposts all Java classes that are concern with Database connectivity.
(a) javax.sql
(b) java.mysql
(c) java.sql
(d) com.sql
Answer: c
Page 43 of 62
Q. S In the below statement, which type of query can be used with executeUpdate( ) method.statement.executeUpdate(query here)
(a) Insert, Update, Delete
(b) Insert, Select, Delete
(c) Only Select
(d) Any Query
Answer: a
Page 44 of 62
O. 12 Which of the following method is supported by Statement interface?
(a) public boolean execute(String query)
(b) public ResultSet executeOuery(String query)
(c) public int executeUpdate(String query)
(d) All of above
Answer: d
O. 15 How many steps are used to connect any java application with the database using JDBC ?
(a) 5
(b) 4
(c) 3
(d) 6
Answer: a
Page 45 of 62
D. 19 Which kind of driver converts JDBC calls into calls on the Client API for Oracle, Sybase, Informix, BM DB2, or
other DBMS
(a) JDBC ODBC bridge + ODBC Driver
(b) Native API partly- Java Driver
(c) JDBC- Net pure Java Driver
(d) Native Protocol Pure Java Driver
Answer: b
D. 20 Which method executes an SQL statement that may return multiple results?
(a) executeUpdate( )
(b) executeQuery( )
(c) execute( )
(d) noExecute( )
Answer: b
D. 23 Which of the following function is used to find the column count of the particular ResultSet.
(a) getMetadata( )
(b) metadata( )
(c) getColumnCount( )
(d) getCount( )
Answer: c
Q. 24 The JDBC-ODBC bridge supports how many concurrent open statements per connection ?
(a) 1
(b) 0
(c) Does not support connection
(d) None of these
Answer: a
Page 46 of 62
D. 26 Microsoft Access data in file format.
(a) .DAT
(b) .MDB
(c) .MSSQL
(d) .OBJ
Answer: b
Q. 32 Which of the following is used generally for reading the content of the database?
(a) DabaseData
(b) DabaseData
(c) ResultSet
(d) DatabaseResult
Answer: c
Page 47 of 62
D. 33 The syntax to create a table named “Course”,should begin with
(a) create new table course
(b) create table course
(c) table course create
(d) new table course
Answer: b
A. Missing semicolon
B. Missing (
C. Missing }
D. Missing statement.
Q. 35. 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.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:0DSN",”","");Statement s=c.createStatement(); ResultSet
rs=s.executeQuery("select*from StudTable”);
System .out.printIn("Name" + " \t " + "Roll No" * " \t " + "Avg"); while(rs.next())
A. Missing semicolon
B. Missing (
C. Missing }
D. Missing statement.
Page 48 of 62
Q. 36. Consider the following program.
What should be the correction done in the program to get correct output?import java.sql.*;
class Ddemo1
A. Error in main()
B. Error in loop
C. Error in connection statement
D. Error in close()
\t \t”+rs.getDoubIe(3));
s.close();
c.close();
A. Missing semicolon
B. Missing {
C. Missing }
D. Missing package statement.
Page 49 of 62
Q. 38. Consider the following program
Select the statement that should be added to the program to get correct output.import java.sql.*;
public class db15
System.out.printIn(rs.getString(1)+"\t"+rs.getInt(2)+"\t"+rs.getDoubIe(3));
s.close();
c.close();
A. s.executeUpdate()
B. c.createStatement( )
C. s.close()
D. c.close()
Page 50 of 62
06 - Servlets Marks:-14
Content of Chapter:•
6.1 Servlet Type of Servlet, Servlet life cycle
6.2 Creating Simple Servlet: The Servlet API, javax.servlet Package, Servlet Interface, Servlet
Config Interface, ServletContext Interface,ServIetRequest ,ServIetResponse,GenericServIet Class
6.3 The Javax,servIet.httppPackage:HttpServletRequest Interface, HttpServletResponse Interface,
HttpSession Interface, Cookie Class, HttpServlet CIass,HttpSessionEvent Class,
HttpSessionBindingEvent Class
6.4 Handling Http Request and Responses, Handling HTTP GETRequest, Handling Http POSTRequest
6.5 Cookies and Session Tracking
Q. 1 JSP embeds in
(a) Servlet, HTML
(b) HTML, Java
(c) HTML, Servlet
(d) Java, HTML
Answer: d
Page 51 of 62
D. 5 Identify the proper syntax of doGet( ).
(a) void doGet(HttpResponse res,HttpRequest req) throws IOException, ServletException
(b) void doGet(HttpRequest req,HttpResponse res) throws IOException, ServletException
(c) void doGet(HttpResponse res) throws IOException, ServletException
(d) void doGet(HttpRequest req) throws IOException, ServletException
Answer: b
D. 7 Which JSP tag is used to transfer for processing another JSP page?
(a) <jsp:incIude>
(b) <jsp:forward>
(c) <jsp:useBean>
(d) <jsp:use:incIude>
Answer: b
Q. 8 An application wants to invalidate the session both programmatically and declaratively. Select the
best match to do this.
(a) httpRequest.getSession( ).end( )
<session-config»<session-timeout-interval»
time_in minutes </session-timeout-intervaI>
</session-config>
(b) httpRequest.getSession( ).invalidate( )
<session-config><session-timeout>
time_in minutes </session-timeout>
</session-config>
(c) httpRequest.getSession( ).close( )
<session-config><session-timeout>
time_in minutes </session-timeout>
</session-config>
(d) httpRequest.getSession( ).invalidate( )
<session-config> <session-duration>
time_in minutes </session-durations
</session-config>
Answer: b
Page 52 of 62
Q. 10 State true or false for following statements.
(i) JavaBeans slow-down software development process.
(ii) Java Servlets do not have built-in multithreaded feature.
(a) false, false
(b) false, true
(c) true, false
(d) true, true
Answer: a
Q. 11 is a small piece of information that is passed back & forth in HTTP request & response.
(a) Servlet
(b) Applet
(c) Cookie
(d) Session
Answer: c
Q. 14 Apache Tomcat is
(a) Servlet
(b) Java Program
(c) API
(d) Web server capable of running Java programs
Answer: d
Page 53 of 62
D. 17 Life cycle of a servlet is managed by
(a) Servlet Context
(b) Servlet Container
(c) Supporting protocol
(d) All of the above
Answer: b
D. 18 To send binary output in the response, the following method of HttpServlet response many be used to get the
appropriate Writer/Stream object.
(a) getstream( )
(b) getoutputstream( )
(c) getBianaryStream( )
(d) getWriter( )
Answer: b
D. 21 Which method is used to specify before any lines that used the PrintWriter?
(a) setPageType( )
(b) setContextType( )
(c) setContentType( )
(d) setResponseType( )
Answer: c
D. 23 The following methods belongs to the life cycle methods of the servlet.
(a) init( )
(b) service( )
(c) destroy( )
(d) All of the above
Answer: d
Page 54 of 62
Q. 24 Java servlet
(i) is a key component of the server side java development.
(ii) is a small pluggable extension to a server that enhances functionality
(iii) runs only in windows OS
(iv) allows developers to customize any java enabled server
(a) i, ii and iii are true
(b) i,iii and iv are true
(c) ii,iii and iv are true
(d) i,ii and iv are true
Answer: d
D. 34 Difference between doGet() and doPost() methods is . Select any of given options
A. In doGet() the parameters are appended to the URL and sent along with header information.
B. In doPost(),wiII send the information through a socket back to the webserver and it won't show up in the URL
bar.
C. doGe () is a request for information;
D. doPost() provides information (such as placing an order) that the server is expected to remember
(a) All above are valid differences
(b) Only A and B
(c) Only C and D
(d) A, B, C are valid differences.
Q. 35.Choose missing statements in following code from given options.public class
session1 extends HttpServlet
Page 56 of 62
D. 36. In following Java program fill statement showing ***.Select any one option fro given options importjavax.servlet.*; importjavax.servlet.http.*;
public class AddCookieServlet extends HttpServlet
A. IoException
B. MalformedURLException
C. Arithmetic Exception
D. UnknownHostException
Q. 38. Consider the following program. Identify the missing statement from the output.import java.net.*;
class URLDemo
Page 57 of 62
Q. 39. Consider the following program and identify the missing statement.
class URLDemo
A. Missing semicolon
B. Missing package statement
C. Missing initialization
D. None of the above
Page 58 of 62