22517 new Questions Set
1 Which package is required for an adapter classes?
A. java.awt.event
B. java.lang
C. java.util
D. java.swing
Answer optiona
Marks: 1
An adapter class provides an empty implementation of all
2 methods in an __________________ .
A. inheritance
B. class
C. Class ,Object
D. event listener interface
Answer optiond
Marks: 1
3 Which one of the following is adapter class?
A. WindowAdapter
B. KeyAdapter
C. MouseAdapter
D. All the above
Answer optiond
Marks: 1
What is the output of following code?
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class FrameClosing2 extends Frame
{
public FrameClosing2()
{
CloseMe cm = new CloseMe();
addWindowListener(cm);
setTitle("Frame closing Style 2");
setSize(300, 300);
4 setVisible(true);
}
public static void main(String args[])
{
new FrameClosing2();
}
}
class CloseMe extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
A.
B.
C.
D.
Answer optionc
Marks: 2
5 _________ class have the KeyListerner interface.
A. KeyListernerAdapter
B. KeyAdapter
C. Adapter
D. None
Answer optionb
Marks: 1
Write correct word at blank spaces.
f.addWindowListener(new _____________
{
6 public void windowClosing(WindowEvent e)
{
System.exit(0);
}
________
A. } and );
B. WindowAdapter() and });
C. KeyAdapter() and });
D. Window and ;
Answer optionb
Marks: 2
Identify the correct adapter name and event name.
public class MyFocusListener extends _______________
{
public void focusGained(_________________ fe)
7 {
Button button = (Button) fe.getSource();
label.setText(button.getLabel());
}
}
A. Focusevent, Focusadapter
B. FocusAdapter, Event
C. FocusAdapter, FocusEvent
D. Adapter, FocusEvent
Answer optionc
Marks: 2
8 Adapter classes are an ____________class for receiving various events.
A. Abstract
B. Inner
C. Inline
D. Inherited
Answer optiona
Marks: 1
9 Adapter classes are used to create _________objects.
A. Class
B. Method
C. Package
D. Listener
Answer optiond
Marks: 1
10 Identify the class which is not an adapter class?
A. KeyAdapter
B. FocusAdapter
C. ItemAdapter
D. MouseMotionAdapter
Answer optionc
Marks: 1
11 Adapter classes are used to ___________ the process of event handling.
A. solve
B. simplify
C. avoid
D. create
Answer optionb
Marks: 1
12 An _________ class listener interface and Event class Listener interfa
A. adapter
B. Static
C. Inner
D. Super
Answer optiona
Marks: 1
13 ____________is a subclass of ComponentEvent.
A. InputEvent
B. ContainerEvent
C. TextEvent
D. WindowEvent
Answer optionb
Marks: 1
An adapter class provides an _________ implementation of all methods i
14 interface.
A. pluggable
B. simple
C. empty
D. Interface
Answer optionc
Marks: 1
15 Which of the following method does not belongs to WindowListerner in
A. windowActivated
B. windowClosed
C. windowClosing
D. windowReactivated
Answer optiond
Marks: 1
Which of the following method is invoked when a window is changed fro
16 minimized state?
A. windowActivated()
B. windowClosed()
C. windowClosing()
D. windowIconified()
Answer optiond
Marks: 1
17 What is adapter class for component listener interface?
A. Component
B. ComponentAdapter
C. ComponentListenerAdapter
D. None
Answer optionb
Marks: 1
18 Whether adapter classes use the methods of event classes?
A. Yes
B. No
C. Sometimes
D. Depends on some requirement
Answer optiona
Marks: 1
19 Which of these methods is defined in MouseMotionAdapter class?
A. mouseDragged()
B. mousePressed()
C. mouseReleased()
D. mouseClicked()
Answer optiona
Marks: 1
20 Which of these is a superclass of all Adapter classes?
A. Applet
B. ComponentEvent
C. Event
D. InputEvent
Answer optiona
Marks: 1
If an adapter class is inherited , there is no need of implementing a
21 listener interfaces .
A. Sometimes
B. Never
C. always
D. None
Answer optionc
Marks: 1
22 Adapter class can be also used for incorporating ___________property o
A. Inheritance
B. Polymorphism
C. Encapsulation
D. All of the above
Answer optionc
Marks: 1
23 In Adapter class it is sufficient to include only the methods required
A. True
B. False
C. Sometimes
D. Never
Answer optiona
Marks: 1
24 Adapter class makes programmers task easier .
A. Sometime
B. True
C. False
D. Never
Answer optionb
Marks: 1
Filling the blank.
25
this.addComponentListener(new ______________________ {
public void componentShown(ComponentEvent evt) {
System.out.println("componentShown");
}
});
A. Component()
B. componentadapter()
C. ComponentAdapter()
D. ContainerAdapter()
Answer optionc
Marks: 1
What is the output of following code?
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code="AdapterDemo" width=300 height=100>
</applet>
*/
public class AdapterDemo extends Applet {
public void init() {
addMouseListener(new MyMouseAdapter(this));
26 }
}
class MyMouseAdapter extends MouseAdapter {
AdapterDemo adapterDemo;
public MyMouseAdapter(AdapterDemo adapterDemo) {
this.adapterDemo = adapterDemo;
}
// Handle mouse clicked.
public void mouseClicked(MouseEvent me) {
adapterDemo.showStatus("Mouse clicked");
}
}
A. Mouse moved
B. Mouse dragged
C. Mouse pressed
D. Mouse clicked
Answer optiond
Marks: 2
27 _____________is a superclass of ContainerEvent .
A. ComponentEvent
B. WindowEvent
C. InputEvent
D. MouseMotionEvent
Answer optiona
Marks: 1
In an adapter class program, if it contains 5 methods, how many method
28 overriden?
A. 1
B. 2
C. 4
D. 5
Answer optiond
Marks: 1
29 Which is the abstract adapter class for receiving keyboard focus ev
A. FocusListener
B. FocusAdapter
C. AdapterFocus
D. AdapterListerner
Answer optionb
Marks: 1
30 Adapter Class and interfaces are same.
A. Sometimes
B. Never
C. True
D. False
Answer optiond
Marks: 1
31 Adapter class saves _________.
A. Time
B. Code
C. Space
D. All of the above
Answer optiond
Marks: 1
Following are the integer constants which does not belong to
32 ComponentEvent class .
A. COMPONENT_HIDDEN
B. COMPONENT_ICONIFIED
C. COMPONENT_MOVED
D. COMPONENT_SHOWN
Answer optionb
Marks: 1
__________ is a superclass of all AWT events that are handled by the
33 model.
A. AWTEvent
B. Event
C. UtilityEvent
D. AWT
Answer optiona
Marks: 1
A class which adapts methods of another class by giving different name
34 the same methods is called as __________.
A. Inner Class
B. Simple Class
C. Adapter Class
D. Inherited Class
Answer optionc
Marks: 1
If a class MyWindowAdapter extends WindowAdapter and implements the wi
35 method. How to register this class?
A. this.addWindowListener(new MyWindowAdapter());
B. this.addWindow(new MyWindowAdapter());
C. this.addWindowAdapter(new MyWindowAdapter());
D. this.addWindowWindow(new MyWindowAdapter());
Answer optiona
Marks: 2
36 Commonly used methods of CardLayout class are____________
A. public void next(Container parent)
B. public void previous(Container parent)
C. public void first(Container parent)
D. all the above
Answer optiond
Marks: 1
Java allows a programmer to write a class within another class,is call
37 _______________ .
A. Abstract Class
B. Inner Class
C. Derived Class
D. Simple Class
Answer optionb
Marks: 1
38 What are the different types of inner classes ?
A. Local
B. Anonymous
C. Both A & B
D. None
Answer optionc
Marks: 1
Fill the proper name of class.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code="AdapterDemo" width=300 height=100>
</applet>
*/
public class AdapterDemo extends Applet {
public void init() {
addMouseListener(new MyMouseAdapter(this));
39 }
}
class MyMouseAdapter extends MouseAdapter {
_________________ adapterDemo;
public MyMouseAdapter(AdapterDemo adapterDemo) {
this.adapterDemo = adapterDemo;
}
// Handle mouse clicked.
public void mouseClicked(MouseEvent me) {
adapterDemo.showStatus("Mouse clicked");
}
}
A. AdapterDemo
B. adapterdemo
C. AdapterDemo1
D. Adapter
Answer optiona
Marks: 2
40 Generates _____________ when the user enters a character.
A. Text Event
B. Character Event
C. Label Event
D. TextField Event
Answer optiona
Marks: 1
41 MouseWheelEvent defines integer constants.
A. WHEEL_BLOCK_SCROLL,WHEEL_UNIT_SCROLL
B. BLOCK_SCROLL,UNIT_SCROLL
C. WHEEL_SCROLL,BLOCK_SCROLL
D. WHEEL_PAGE_SCROLL,WHEEL_TRACK_SCROLL
Answer optiona
Marks: 1
42 What is the return type of isTemporary( ) method?
A. int
B. Long
C. String
D. boolean
Answer optiond
Marks: 1
The abstract class ______________ is a subclass of ComponentEvent and
43 for component input events.
A. FocusEvent
B. InputEvent
C. WindowEvent
D. TextEvent
Answer optionb
Marks: 1
44 Inner class can access all the members of outer class including_______
methods.
A. Private
B. Public
C. Protected
D. Static
Answer optiona
Marks: 1
45 ____________________can be achieved by using Inner Class.
A. Code Extension
B. Code Inheritance
C. Code Optimization
D. Code Development
Answer optionc
Marks: 1
46 The __________method returns the object that generated the event.
A. Adjustable( )
B. getModifiers( )
C. getAdjustable( )
D. getAdjust( )
Answer optionc
Marks: 1
47 ________ is a class which is declared inside the class or interface.
A. Inner Class
B. Inherited Class
C. Nested Interfaces
D. Static Class
Answer optiona
Marks: 1
48 To handle any events of mouse, you must implement following interfaces
A. MouseListener, MouseMotionListener, MouseWheelListener
B. MouseListener, MouseWheelListener
C. MouseMotionListener, MouseWheelListener
D. MouseListener
Answer optiona
Marks: 1
The _________method returns a reference to the component that was adde
49 from the container.
A. getParent( )
B. get( )
C. getTime( )
D. getChild( )
Answer optiond
Marks: 1
50 A class that have no name is known as_______________ inner class in ja
A. Anonymous
B. Local
C. Nested
D. Static
Answer optiona
Marks: 1
51 Which are two ways to create Java Anonymous inner class ?
A. Class,Interface
B. Class,Object
C. Interface,Object
D. Class,Constructor
Answer optiona
Marks: 1
52 Which event is generates, when button is pressed?
A. TextEvent
B. ItemEvent
C. InputEvent
D. ActionEvent
Answer optiond
Marks: 1
53 Which event is generates when checkable menu item is selected or desel
A. ActionEvent
B. InputEvent
C. ItemEvent
D. TextEvent
Answer optionc
Marks: 1
54 If you compile a file containing inner class how many .class files are
A. 1
B. 4
C. 3
D. 2
Answer optiond
Marks: 1
When a component is added to and removed from a container, _________
55 generates.
A. ComponentEvent
B. WindowEvent
C. FrameEvent
D. ContainerEvent
Answer optiond
Marks: 2
56 What is the output of the following code :-
class TestMemberOuter1
{
private int data=30;
class Inner{
void msg(){System.out.println("data is "+data);}
}
void display()
{
Inner in=new Inner();
in.msg();
}
public static void main(String args[])
{
TestMemberOuter1 obj=new TestMemberOuter1();
obj.display();
}
}
A. error
B. data is Null
C. data is 30
D. data is 0
Answer optionc
Marks: 2
57 The AdjustmentEvent class defines integer constants.
A. ALT, CTRL, META, and/or SHIFT
B. BLOCK_DECREMENT, BLOCK_INCREMENT,TRACK
C. ALT, CTRL, UNIT_INCREMENT,UNIT_DECREMENT
D. UNIT_INCREMENT,UNIT_DECREMENT,SHIFT
Answer optionb
Marks: 1
Since Nested class is a member of its enclosing class Outer, you can
58 notation to access Nested class and its members.
A. ->(arrow)
B. .(dot)
C. * (asterisk)
D. &(ampersand)
Answer optionb
Marks: 1
59 Inner classes provides______________ mechanism in Java.
A. Safety
B. Protection
C. Security
D. Risk Handling
Answer optionc
Marks: 1
60 ItemEvent class defines the integer constants.
A. DESELECT,SELECT
B. DESELECTED,SELECTED
C. ENABLED,NOTENABLED
D. CHECKED, UNCHECKED
Answer optionb
Marks: 1
61 The non-static nested classes are also known as _______________ .
A. event class
B. class
C. adapter classes
D. inner classes
Answer optiond
Marks: 1
62 Inner class mainly used for _________________ .
A. for Code Optimization
B. to access all the members
C. to develop more readable and maintainable code
D. all of these
Answer optiond
Marks: 1
63 Can outer Java classes access inner class private members?
A. No
B. Sometimes
C. Yes
D. Never
Answer optionc
Marks: 1
What is the output of following?
import java.applet.*;
import java.awt.event.*;
/*
<applet code="InnerClassDemo" width=200 height=100>
</applet>
*/
64 public class InnerClassDemo extends Applet {
public void init() {
addMouseListener(new MyMouseAdapter());
}
class MyMouseAdapter extends MouseAdapter {
public void mousePressed(MouseEvent me) {
showStatus("Mouse Pressed");
}
}
}
A. Mouse Clicked
B. Mouse Moved
C. Mouse Dragged
D. Mouse Pressed
Answer optiond
Marks: 2
Fill in the blanks.
import java.applet.*;
import java.awt.event.*;
/*
<applet code="InnerClassDemo" width=200 height=100>
</applet>
*/
public class InnerClassDemo extends Applet {
65 public void init() {
__________ (new MyMouseAdapter());
}
class MyMouseAdapter extends _________________
{
public void mousePressed(MouseEvent me) {
showStatus("Mouse Pressed");
}
}
}
A. addMouse, Adapter
B. addMouseListener, Adapter
C. addMouseListener, MouseAdapter
D. addListener, MouseAdapter
Answer optionc
Marks: 2
What is the output of the following java program?
class Outer {
void outerMethod() {
System.out.println("inside outerMethod");
// Inner class is local to outerMethod()
class Inner {
void innerMethod() {
System.out.println("inside innerMethod");
}
66 }
Inner y = new Inner();
y.innerMethod();
}
}
class MethodDemo {
public static void main(String[] args) {
Outer x = new Outer();
x.outerMethod();
}
}
A. inside innerMethod inside outerMethod
B. inside outerMethod inside innerMethod
C. inside innerMethod inside innerMethod
D. inside outerMethod inside outerMethod
Answer optionb
Marks: 2
Identify the correct adapter name and event name.
class MyWindowAdapter extends ________________
{
67 public void windowClosing(_____________ e)
{
System.exit(0);
}
}
A. Window, WindowEvent
B. WindowAdapter, Window
C. WindowAdapter, WindowEvent
D. Adapter, Event
Answer optionc
Marks: 2
In the following code, what is the name of the inner class?
Public class Periodical
{
long ISBN;
public class Book
{
68 public long getISBN()
{
retrun ISBN;
}
}
}
A. getISBN
B. Periodical
C. ISBN
D. Book
Answer optiond
Marks: 2
Identify the type of class for following code?
import java.applet.*;
import java.awt.event.*;
/*<applet code="Demo" width=300 height=100>
</applet>
*/
public class Demo extends Applet
{
69 public void init()
{
addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent me)
{ showStatus("Mouse Pressed");
}
});
}
}
A. Inner Class
B. Adapter class
C. Anonymous Inner Class
D. static class
Answer optionc
Marks: 2
In case of _______ we can implement only required
70 methods of any interface.
A. interface
B. package
C. adapter classes
D. event classes
Answer optionc
Marks: 1
The ___________ method returns a value that indicates which modifier k
71 when the event was generated.
A. getModifiers( )
B. getAdjustable( )
C. Modifiers( )
D. Adjustable( )
Answer optiona
Marks: 1
getLocalHost() method simply returns the InetAddress object which
72 represents______________
A. host name
B. machine name
C. local host
D. remote host
Answer optionc
Marks: 1
73 The getByName() method returns an ________________ with host name
A. IP address
B. InetAddress Object
C. port number
D. IPv4
Answer optiona
Marks: 1
getAllByName() method returns an array of_____________ that represents
74 addresses that specific host name has
A. host names
B. InetAddresses
C. ipaddresses
D. objects
Answer optionb
Marks: 1
what is the output of following program
import java.net.*;
class Demo
{
public static void main(String arg[]) throws UnknownHostException
75 {
InetAddress ipa=InetAddress.getLocalHost();
System.out.println(ipa);
}
}
A. host name/IP address
B. iPAddress/Host name
C. IPAddress
D. Host name
Answer optiona
Marks: 2
76 Which type of Statement can execute parameterized queries?
A. ParameterizedStatement
B. PreparedStatement
C. ParameterizedStatement and CallableStatement
D. All kinds of Statements
Answer optionb
Marks: 1
77 How can you retrieve information from a ResultSet?
A. By invoking the method get(String type) on the ResultSet, where type i
By invoking the method get(Type type) on the ResultSet, where Type is
B. represents a database type
C. By invoking the method getValue(), and cast the result to the desired
By invoking the special getter methods on the ResultSet: getString(),
D. getClob()
Answer optiond
Marks: 1
78 Which type of statement can execute parameterized queries ?
A. PreparedStatement
B. ParameterizedStatement
C. CallableStatement
D. All of the Above
Answer optiona
Marks: 1
79 What is the meaning of ResultSet.TYPE_SCROLL_INSENSITIVE
A. This means that the ResultSet is insensitive to scrolling
This means that the Resultset is sensitive to scrolling, but insensit
B. i.e. not updateable
This means that the ResultSet is sensitive to scrolling, but insensiti
C. by others
The meaning depends on the type of data source, and the type and versi
D. you use with this data source
Answer optionc
Marks: 1
80 What statements are correct about JDBC transactions
A. A transaction is a set of successfully executed statements in the dat
B. A transaction is finished when commit() or rollback() is called on the
C. A transaction is finished when commit() or rollback() is called on the
D. A transaction is finished when close() is called on the Connection obj
Answer optiond
Marks: 1
81 What happens if you call the method close() on a ResultSet object?
A. the method close() does not exist for a ResultSet. Only Connections ca
B. the database and JDBC resources are released
C. you will get a SQLException, because only Statement objects can close
the ResultSet, together with the Statement which created it and the Co
D. the Statement was retrieved, will be closed and release all database a
Answer optionb
Marks: 1
82 What happens if you call deleteRow() on a ResultSet object?
A. The row you are positioned on is deleted from the ResultSet, but not f
B. The row you are positioned on is deleted from the ResultSet and from t
The result depends on whether the property synchronizeWithDataSource
C. false.
You will get a compile error: the method does not exist because you ca
D. from a ResultSet.
Answer optionb
Marks: 1
83 What is correct about DDL statements
DDL statements are treated as normal SQL statements, and are executed
A. execute() method on a Statement
B. To execute DDL statements, you have to install additional support file
DDL statements can not be executed by making use of JDBC, you should u
C. database tools for this
D. Support for DDL statements will be a feature of a future release of JD
Answer optiona
Marks: 1
Which of the following statements is false as far as different type of
84 concern in JDBC?
A. Regular Statement
B. Prepared Statement
C. Callable Statement
D. Interim Statement
Answer optiond
Marks: 1
JDBC facilitates to store the java objects by using which of the metho
85 Statement
1. setObject () 2. setBlob() 3. setClob()
A. 1, 2
B. 1, 2,3
C. 1,3
D. 2,3
Answer optionb
Marks: 1
86 _______method to establish actual database connection.
A. executeQuery()
B. executeUpdate()
C. getConnection()
D. prepareCall()
Answer optionc
Marks: 1
Which of the following describes the correct sequence of the steps inv
connection with a database.
1. Loading the driver
87 2. Process the results.
3. Making the connection with the database.
4. Executing the SQL statements.
A. 1,3,4,2
B. 1,2,3,4
C. 2,1,3,4
D. 4,1,2,3
Answer optiona
Marks: 1
88 Which method is used to perform DML statements in JDBC?
A. execute()
B. executeQuery()
C. executeUpdate()
D. executeResult()
Answer optionc
Marks: 1
Can we retrieve a whole row of data at once, instead of calling an in
89 ResultSet.getXXX method for each column ?
A. No
B. Yes
C. Statement is incorrect
D. None of the above
Answer optionb
Marks: 1
90 Are Prepared Statements actually compiled?
A. Yes
B. No
C. Statement is incorrect
D. None of the above
Answer optiona
Marks: 1
In order to transfer data between a database and an application writte
91 programming language, the JDBC API provides which of these methods?
A. Methods on the ResultSet class for retrieving SQL SELECT results as Ja
Methods on the PreparedStatement class for sending Java types as SQL s
B. parameters.
C. Methods on the CallableStatement class for retrieving SQL OUT paramete
D. All mentioned above
Answer optiond
Marks: 1
92 _________calls get converted into native c or c++ API calls.
A. API
B. ODBC
C. JDBC API
D. None of the above.
Answer optionc
Marks: 1
93 Which method Drops all changes made since the previous commit/rollback
A. public void rollback()
B. public void commit()
C. public void close()
D. public Statement createStatement()
Answer optiona
Marks: 1
94 Which of the following is used to set the maximum number of rows can
A. setMaxRows(int i)
B. setMinRows(int i)
C. getMaxrows(int i)
D. getMinRows(int i)
Answer optiona
Marks: 1
____method of ResultSet is used to move the cursor to the row next fro
95 position.
A. fetch method
B. current method
C. next method
D. access method
Answer optionc
Marks: 1
Which of the following encapsulates an SQL statement which is passed t
96 be parsed, compiled, planned and executed?
A. DriverManager
B. JDBC driver
C. Connection
D. Statement
Answer optiond
Marks: 1
97 The interface ResultSet has a method, getMetaData(), that returns a/an
A. Tuple
B. Value
C. Object
D. Result
Answer optionc
Marks: 1
98 Which method is used to find the number of column in ResultSet?
A. getNumberOfColumn()
B. getMaxColumn()
C. getColumnCount()
D. getColumns()
Answer optionc
Marks: 1
99 commit() method is belongs to which interface?
A. ResultSet
B. Statement
C. PreparedStatement
D. Connection
Answer optiond
Marks: 1
100 Which one is the correct syntax for creating a Statement?
A. Statement stmt = connection.createStatements();
B. Statement stmt = connection.preparedStatement();
C. Statement stmt = connection.createStatement();
D. none of these
Answer optionc
Marks: 1
101 Which statement is correct?
A. ResultSet rs = stmt.selectQuery("SELECT ROLLNO,STUDNAME FROM STUDENT")
B. ResultSet rs = stmt.executeSelect("SELECT ROLLNO,STUDNAME FROM STUDENT
C. ResultSet rs = stmt.executeUpdate("SELECT ROLLNO,STUDNAME FROM STUDENT
D. ResultSet rs = stmt.executeQuery("SELECT ROLLNO,STUDNAME FROM STUDENT"
Answer optiond
Marks: 1
102 INSERT, DELETE, UPDATE comes under ?
A. Data Modification Language
B. Data Definition Language
C. Data Control Language
D. Data Manipulation Language
Answer optiond
Marks: 1
103 The return type of execute(String query) is?
A. int
B. ResultSet
C. boolean
D. void
Answer optionc
Marks: 1
Consider the following program. Select the missing statement in given
import java.sql.*;
class PreparedExample{
public static void main(String args[]){
try{
104 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:snrao","scott
PreparedStatement stmt=con.prepareStatement("select * from stud
rollno=?)");
stmt.setInt(1,1);
------------------------------------------
while(rs.next())
{}
con.close();
}catch(Exception e){ System.out.println(e);}
}
}
A. stmt.setString(2,"Ratan");
B. int i=stmt.executeQuery();
C. ResultSet rs=stmt.executeQuery();
D. ResultSet rs=stmt.executeQuery("select * from student―);
Answer optionc
Marks: 2
Consider the following code. To execute the query, which of the follow
used?
String sql = "update people set firstname=? , lastname=? where id=?";
105 preparedStatement = connection.prepareStatement(sql); preparedStatemen
"Gary");
preparedStatement.setString(2, "Larson");
preparedStatement.setLong (3, 123);
A. int rowsAffected = preparedStatement.executeUpdate();
B. ResultSet rs=preparedStatement.executeQuery(sql);
C. int rowsAffected = preparedStatement.executeQuery(sql);
D. ResultSet rs=preparedStatement.executeUpdate();
Answer optiona
Marks: 2
106 which method is used to insert image in database
A. statement.getImage()
B. statement.getDouble()
C. statement.getBLOB()
D. statement.getIcon()
Answer optionc
Marks: 1
All raw data types (including binary documents or images) should be re
107 the database as an array of
A. byte
B. int
C. char
D. long
Answer optiona
Marks: 1
108 Consider the following code and Select the missing statement in given
import java.sql.*;
class MySQL
{
public static void main(String args[]){
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection(
"jdbc:mysql://localhost:3306/dsn","root","root");
Statement stmt=con.createStatement();
------------------------------------------------------------
while(rs.next())
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3
con.close();
}catch(Exception e){ System.out.println(e);}
}
}
A. ResultSet rs=stmt.runQuery("select * from emp");
B. ResultSet rs=stmt.executeQuery("select * from emp");
C. int n=stmt.executeQuery("select * from emp");
D. int n=stmt.executeUpdate("select * from emp");
Answer optionb
Marks: 2
Consider the following program. Find which statement contains error
import java.awt.*;
import javax.swing.*;
/*
<applet code="JTableDemo" width=400 height=200>
</applet>
109 */
public class JTableDemo extends JApplet
{
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
final String[] colHeads = { "Name", "Phone", "Fax" };
final Object[][] data = {
{ "Pramod", "4567", "8675" },
{ "Tausif", "7566", "5555" },
{ "Nitin", "5634", "5887" },
{ "Amol", "7345", "9222" },
{ "Vijai", "1237", "3333" },
{ "Ranie", "5656", "3144" },
{ "Mangesh", "5672", "2176" },
{ "Suhail", "6741", "4244" },
{ "Nilofer", "9023", "5159" },
{ "Jinnie", "1134", "5332" },
{ "Heena", "5689", "1212" },
{ "Saurav", "9030", "1313" },
{ "Raman", "6751", "1415" }
};
JTable table = new JTable(data, colHeads);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(table, v, h);
contentPane.add(jsp, BorderL
A. No error
B. error
C. compile time error
D. Run time errror
Answer optiona
Marks: 2
Consider the following code and write the value of String sql to delet
employee.
import java.sql.*;
import java.util.*;
110
public class DeleteRecord
{
public static void main(String args[]) throws Exception
{
String sql;
Scanner sc=new Scanner(System.in);
System.out.println("Please Enter the ID no:");
int num = sc.readInt();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:EMP","scott"
Statement stmt=con.createStatement();
int affectedRecords = stmt.executeUpdate(sql);
br.close();
stmt.close();
con.close();
}
}
A. sql="delete from Employee where empid="+ num
B. sql="delete * Employee where empid="+ num
C. sql=" select * from Employee "
D. sql="delete from Employee where empid="
Answer optiona
Marks: 2
Following four methods belongs to which class?
1) public void add(Component c)
111 2) public void setSize(int width,int height)
3) public void setLayout(LayoutManager m)
4) public void setVisible(boolean)
A. Graphics class
B. Component class
C. Both A & B
D. None of the above
Answer optionb
Marks: 2
Which is the container that does not contain title bar and MenuBars bu
112 components like button, textfield etc?
A. Window
B. Menu bar
C. Panel
D. Output Screen
Answer optionc
Marks: 1
113 Whose object is to be created to show any number of choices in the vis
A. JLabel
B. JButton
C. JList
D. JCheckbox
Answer optionc
Marks: 1
What is used to store partial data results, as well as to perform dyn
114 return values for methods, and dispatch exceptions?
A. Window
B. Button
C. Container
D. Frame
Answer optiond
Marks: 2
115 Which class is used for processActionEvent( ) Processing Method ?
A. JButton,JList,JMenuItem
B. JButton Only
C. JScrollbar
D. None of the above
Answer optiona
Marks: 1
a) It is lightweight.
b) It supports pluggable look and feel.
116 c) It follows MVC (Model View Controller) architecture
Above advantages are of _____________
A. Swing
B. AWT
C. Networking
D. Databases
Answer optiona
Marks: 1
JFrame myFrame = new JFrame ();
117 Any command (such as the one listed above) which creates a new object
(in this case a new JFrame object called myFrame) is generally called
A. Constructor
B. Layout manager
C. Parameter
D. GUI
Answer optiona
Marks: 2
Suppose you are developing a Java Swing application and want to toggle
118 views of the design area. Which of the views given below are present f
toggle?
A. Design View
B. Requirement View
C. Source View
D. Toggle View
Answer optionb
Marks: 2
119 The size of a frame on the screen is measured in:
A. Inches
B. Centimetres
C. Dots
D. Pixels
Answer optiond
Marks: 1
120 The layout of a container can be altered by using which of the followi
A. setLayout(LayoutManager)
B. layoutmanager(LayoutManager)
C. addLayout(LayoutManager)
D. setLayoutManager(LayoutManager)
Answer optiona
Marks: 1
121 In JDBC _____ imports all java classes concerned with database connect
A. javax.sql.*
B. java.mysql.*
C. java.sql.*
D. com.*
Answer optionc
Marks: 1
122 Methods of ResultSet throws ...... exception.
A. IOException
B. SQLException
C. MethodNotFoundException
D. ResultSetException
Answer optionb
Marks: 1
123 Which of the following is FALSE with reference to JDBC Driver
A. All drivers implements the java.sql.Driver interface.
B. driver classes are not supplied by the database vendor
C. Driver class return a java.sql.Connection object.
D. None of the Above
Answer optionb
Marks: 1
124 How do you indicate where a component will be positioned using Flowlay
A. North, South, East, West
B. Assign a row/column grid reference
C. Do nothing, the FlowLayout will position the component
D. Pass a X/Y percentage parameter to the add method
Answer optionc
Marks: 2
Match the following
i) Type 1 Driver a) Native API, partly Java
125 ii)Type 2 Driver b) Pure Java direct to database
iii)Type 3 Driver c) JDBC-ODBC bridge
iv)Type 4 Driver d) Pure Java to database middleware
A. i -> c, ii -> b , iii -> d, iv -> a
B. i -> c, ii -> a , iii -> d, iv -> b
C. i -> c, ii -> a , iii -> b, iv -> d
D. i -> c, ii -> d , iii -> a, iv -> b
Answer optionb
Marks: 1
126 PreparedStatements are used for calling........ statements
A. Interpreted Statements
B. Exceuted statements
C. Resultset statements
D. precompile Statement
Answer optiond
Marks: 1
127 Which TextComponent method is used to set a TextComponent to the read-
A. setReadOnly()
B. setRead()
C. setUpdate()
D. setTextReadOnly()
Answer optiona
Marks: 1
128 Which type of Driver communicate using a network protocol to a middlew
A. Type 1 Driver
B. Type 2 Driver
C. Type 3 Driver
D. Type 4 Driver
Answer optionc
Marks: 1
129 Which method will cause a JFrame to get displayed?
A. show( )
B. setVisible( )
C. showFrame( )
D. displayFrame( )
Answer optionb
Marks: 1
Which of the Following Drivers Sun describes it as being experimental
130 use only where no other driver is available.
A. Type 1 Driver
B. Type 2 Driver
C. Type 3 Driver
D. Type 4 Driver
Answer optiona
Marks: 1
131 ___________ interface allows storing results of query?
A. ResultSet
B. Connection
C. Statement
D. Result
Answer optiona
Marks: 1
Which of the Following Drivers require native library files to be inst
132 on client systems.
A. Type 1 Driver
B. Type 2 Driver
C. Type 3 Driver
D. Type 4 Driver
Answer optionb
Marks: 1
133 InetAddress also Includes a factory method called____
A. getByAddress()
B. getHostName()
C. getAddress()
D. getIPAddress()
Answer optiona
Marks: 1
134 Which of the following statements are TRUE in case of Type 2 JDBC Driv
A. It use native methods to call vendor-specific API functions.
B. native library files are to be installed on client systems.
C. Both of the Above
D. None of the Above
Answer optionc
Marks: 1
135 in JDBC 2.0 a Connection object is created either by a call to
A. DriverManager.getConnection()
B. DataSource.Connection()
C. Both of the Above
D. None of the Above
Answer optiona
Marks: 1
136 How to create the Tabbed pane in swings?
A. JTab jt=new JTab();
B. JTabPane jt=new JTabPane();
C. JTabP =new JTabP();
D. JTabbedPane jt=new JTabbedPane ();
Answer optiond
Marks: 1
137 In JDBC URL string protocol is always
A. jdbc
B. odbc
C. Jdbc-odbc
D. Any one of the above
Answer optiona
Marks: 1
Choose the correct option to insert rollno and student name into table
138 display its contents
import java.sql.*; class Example1{ public static void main(
("jdbc:oracle:thin:@localhost:1521:xe","system","o
A. PreparedStatement stmt=con.prepareStatement("insert into studen
System.out.println(e);} } }
import java.sql.*; class Example1{ public static void main(
("jdbc:oracle:thin:@localhost:1521:xe","system","o
B. PreparedStatement stmt=con.preparedStatement("insert into stude
stmt.setInt(1,"Ratan"); stmt.setString(2,101); int i=stmt
import java.sql.*; class Example1{ public static void main(
values(?,?)") ; stmt.setInt(1,101); stmt.setString(2,XYZ);
C. i=stmt.executeQuery(); con.close(); }catch(Exception e){
System.out.println(e);} } }
import java.sql.*; class Example1{ public static void main(
("jdbc:oracle:thin:@localhost:1521:xe","system","o
PreparedStatement stmt=con.preparedStatement("insert into stude
D. stmt.setInt(1,101); stmt.setString(2,"Ratan"); int
i=stmt.executeUpdate(); con.close(); }catch(Exception e){
System.out.println(e);} } }
Answer optiond
Marks: 2
what is the output of following program
import java.net.*;
class Demo
139 {
public static void main(String arg[])
{
InetAddress ip=InetAddress.getByName("www.google.com");
System.out.println(ip)
}
A. www.google.com/217.56.216.195
B. www.google.com
C. 217.56.216.195
D. All of the above
Answer optiona
Marks: 2
What does the following line of code do?
140 JTextfield text = new JTextfield(10);
A. Creates text object that can hold 10 columns of text.
B. Creates text object that can hold 10 rows of text.
C. Creates the object text and initializes it with 10.
D. The code is illegal
Answer optionc
Marks: 1
141 Which of the following is FALSE with reference to JDBC database URL
A. URL string has three components
B. protocol in URL string is always jdbc
C. subprotocol in URL string is always odbc.
D. subname identifies the specific database to connect
Answer optionc
Marks: 1
The Swing component classes that are used to encapsulate a mutually ex
142 buttons ?
A. AbstractButton
B. ButtonGroup
C. JButton
D. Button
Answer optionb
Marks: 1
143 Which class has strong support of the JDBC architecture?
A. The JDBC driver manager
B. JDBC driver test suite
C. JDBC ODBC bridge
D. All of these
Answer optiona
Marks: 1
Connection object can be initialized using the ____________method of t
144 Class.
A. putConnection()
B. setConnection()
C. Connection()
D. getConnection()
Answer optiond
Marks: 1
In model-view-controller (MVC) architecture of swings, model defines
145 the_______________________________
A. Data layer
B. Presentation layer
C. Business-logic layer
D. Both A and C
Answer optiond
Marks: 1
146 Which of the following methods are needed for loading a database drive
A. registerDriver() method
B. Class.forName ()
C. Both A and B
D. getConnection ()
Answer optionb
Marks: 1
147 Disadvantages of MVC architecture can be :
A. Navigation control is decentralized
B. Time consuming
C. both a& b
D. UI components are not user friendly
Answer optionc
Marks: 1
148 Native API converts ____________into the ________________used by DBMS.
A. JDBC API, network protocol
B. JDBC API, Native API calls
C. JDBC API, User call
D. JDBC API, ODBC API calls
Answer optionb
Marks: 1
149 _______ method of DriverManager class is used to establish connection
A. openConnection()
B. getConnection()
C. connect()
D. createConnection()
Answer optionb
Marks: 1
150 . . . . . . helps you to maintain data when you move from controller t
A. View Bag
B. View Data
C. . Temp Data
D. Both A and B
Answer optiond
Marks: 1
What is output of following program
import java.net.*;
class Demo
{
public static void main(String arg[]) throws UnKnownHostException
151 {
InetAddress ipa[]=InetAddress.getAllByName("www.google.com");
for(int i=0;i<ipa.length;i++){
System.out.println(ipa[i]); }
}
}
A. array of hostnames
B. array of hostname/IPaddress
C. array of IPaddress
D. IPAddress/Hostname
Answer optionb
Marks: 2
152 Which of the following view file types are supported in MVC?
A. .cshtml
B. .vbhtml
C. .aspx
D. All of the above
Answer optiond
Marks: 1
153 Can we use view state in MVC?
A. Yes
B. No
C. Both A & B
D. None of the above
Answer optionb
Marks: 1
154 subname part of JDBC URL string NOT contains
A. Database name
B. Username & password
C. Port number
D. Protocol
Answer optiond
Marks: 1
The code below draws a line. What is the color of the line created?
155 g.setColor(Color.red.green.yellow.red.cyan);
g.drawLine(0, 0, 100,100);
A. Red
B. Green
C. Yellow
D. Cyan
Answer optiond
Marks: 1
What does the following code draw? g.setColor(Color.black);
g.drawLine(10, 10, 10,50);
156 g.setColor(Color.RED);
g.drawRect(100, 100, 150, 150);
A. A red vertical line that is 40 pixels long and a red square with sides
B. A black vertical line that is 40 pixels long and a red square with sid
C. A black vertical square that is 50 pixels long and a red square with s
D. A red vertical line that is 50 pixels long and a red square with sides
Answer optionb
Marks: 2
157 boolean equals(Object other) will return_______
A. Returns true if object has same internet address as other.
B. Returns False if object has same internet address as other.
C. Returns true if object has not same internet address as other.
D. Returns null if object has same internet address as other.
Answer optiona
Marks: 1
158 Which method is used to construct a 24-point bold serif font?
A. new Font(Font.SERIF, 24,Font.BOLD);
B. new Font("SERIF", 24, BOLD");
C. new Font("BOLD", 24,Font.SERIF);
D. new Font("SERIF", Font.BOLD,24);
Answer optiond
Marks: 1
159 What is the role of getAddress() method ?
A. returns Ip address of network.
B. Returns a byte array that represents the object's Ip address in the ne
C. Returns an array of object's that represents Ip address .
D. Returns the a byte array of Ip address of network host machine .
Answer optionb
Marks: 1
160 Which of the following type of JDBC driver, is also called Type 3 JDBC
A. JDBC-ODBC Bridge plus ODBC driver
B. Native-API, partly Java driver
C. JDBC-Net, pure Java driver
D. Native-protocol, pure Java driver
Answer optionc
Marks: 1
What will be the following code draw on the screen. Where "g" is a gr
the following code of line
161
g.fillArc(45,90,50,50,90,180);
An arc bounded by a box of height 45, width 90 with a centre point of
A. an angle of 90 degrees traversing through 180 degrees counter clockwis
An arc bounded by a box of height 50, width 50, with a centre point of
B. an angle of 90 degrees traversing through 180 degrees clockwise.
An arc bounded by a box of width 50, height 50, with a top left at coo
C. starting at 90 degrees and traversing through 180 degrees counter cloc
An arc starting at 45 degrees, traversing through 90 degrees clockwise
D. of height 50, width 50 with a centre point of 90, 180.
Answer optionc
Marks: 2
Analyse the following code and fill the appropriate statement in the b
import java.sql.*;
class Demo
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
162 Connection con=DriverManager.getConnection("jdbc:odbc:stud");
Statement stmt=con.createStatement();
ResultSet rs=stmt.________________("select * from student where rollno
System.out.println("RollNo Name Branch"); where(rs.next())
{
System.out.println(rs.getString(1)+" "+rs.getString(2)+" "+rs.getIn
con.close(); } }
A. executeUpdate()
B. executeQuery()
C. execute()
D. All of the Above
Answer optionb
Marks: 2
What will be the output of the following program? The program creates
override the paint method as follows
import java.applet.*;
import java.awt.*;
163 public class HelloWorldApplet extends Applet {
public void paint (Graphics g) {
g.drawString ("Dolly",50,10);
}
}
A. The string "Dolly" will be displayed at the centre of the frame.
B. An error at compilation complaining at the signature of the paint meth
C. The string "Dolly" will be seen at the top of the form
D. The string "Dolly" will be shown at the bottom of the form.
Answer optionc
Marks: 2
What is the output of the following ?
import java.awt.*;
import javax.swing.*;
public class FrameTest
extends JFrame { public FrameTest()
{ add (new JButton("First"));
164 add (new JButton("Second"));
add (new JButton("Third"));
pack();
setVisible(true);
}
public static void main(String args [])
{ new FrameTest(); } }
A. Three buttons are displayed across a window.
B. A runtime exception is generated (no layout manager specified).
C. Only the first button is displayed.
D. Only the third button is displayed.
Answer optiond
Marks: 1
165 Which of the following type of JDBC driver, is also called Type 1 JDBC
A. JDBC-ODBC Bridge Driver
B. Native API/ Partly java driver
C. All java / Net-protocol driver
D. Native protocol / all-java driver
Answer optiona
Marks: 1
166 Which of the following type of JDBC driver, is also called Type 2 JDBC
A. Native API/ Partly java driver
B. JDBC-ODBC Bridge Driver
C. Native protocol / all-java driver
D. All java / Net-protocol driver
Answer optiona
Marks: 1
Suppose a JPanel is added to a JFrame and a JButton is added to the JP
JFrames font is set to 12-point TimesRoman, the JPanels font is set to
167 TimesRoman, and the JButtons font is not set,what font will be taken t
JButtons label?
A. 12- point TimesRoman.
B. 11- point TimesRoman.
C. 10 -point TimesRoman
D. 09 -point TimesRoman.
Answer optionc
Marks: 1
168 Which of the following type of JDBC driver, is also called Type 4 JDBC
A. All java / Net-protocol driver
B. Native protocol / all-java driver
C. Native API/ Partly java driver
D. JDBC-ODBC Bridge Driver
Answer optionb
Marks: 1
What is the result of the following applet code ?
import java.applet.JApplet;
Import javax.swing.*;
public class Sample extends JApplet
{
169 private String text = "Hello World";
public void init()
{
add(new JLabel(text));
}
public Sample (String string)
{
text = string;
}
}
It is accessed form the following
HTML page: <html> <title>Sample Applet</title> <body> <applet code="Sa
width=200
height=200></applet></body></html>.
A. Prints "Hello World"
B. Generates a runtime error
C. . Does nothing
D. Generates a compile time error
Answer optionb
Marks: 2
import java.applet.JApplet;
import javax.swing.*;
public class Sample extends JApplet {
private String text = "Hello World";
public void init()
{
add(new JLabel(text));
}
public Sample (String string)
170 {
text = string;
}
}
It is accessed form the following
HTML page: <html> <title>Sample Applet</title> <body> <applet code="Sa
width=200
height=200></applet></body></html>.
The method setLabel() can be used with what type of Object?
A. Float
B. int
C. JTextField
D. String.
Answer optionc
Marks: 2
Which Swing Component classes that are used to Encapsulates a mutually
171 buttons?
A. AbstractButton
B. ButtonGroup
C. JButton
D. Button
Answer optionb
Marks: 1
172 Which method is used to add tooltip text to almost all components of J
A. getToolTipText()
B. setToolTipText(String s)
C. setToolTip (String s)
D. getToolTipText(String s)
Answer optionb
Marks: 1
173 In Swing the content pane can be obtained by using ________method.
A. getContent()
B. getContentPane()
C. Both A & B
D. getContainedPane()
Answer optionb
Marks: 1
Which one of the following is the correct sequence of activities to pe
174 connectivity in java
Register the Driver class - Create statement - Create connection - Exe
A. Close connection
Register the Driver class - Create connection - Create statement -Exec
B. connection
Create connection - Register the Driver class - Create statement -Exec
C.
connection
Create connection - Create statement - Register the Driver class - Exe
D. Close connection
Answer optionb
Marks: 1
175 Model is the _________ in the MVC architecture.
A. top most level
B. middle most level
C. bottom most level
D. None of the above
Answer optionc
Marks: 1
Double-buffering built in, tool tips, dockable tool bars, keyboard , a
176 cursors, etc. are new features of _______?
A. AWT
B. Networking
C. Swing
D. All of the above
Answer optionc
Marks: 1
177 JCheckBox is ___________________Component .
A. heavyweight
B. mediumweight
C. No weight
D. lightweight
Answer optiond
Marks: 1
178 The default layout manager for the content pane of a swing is :
A. CardLayout
B. GridLayout
C. BorderLayout
D. None of the above
Answer optionc
Marks: 1
Type of server in two-tier architectures which provides data to client
179 pages is called
A. transaction server
B. functional server
C. disk server
D. data server
Answer optiond
Marks: 1
Application program interface in two tier architecture database manage
180 provided by the
A. close module connectivity
B. open module connectivity
C. close database connectivity
D. open database connectivity
Answer optiond
Marks: 2
181 Database system compiles query when it is
A. prepared
B. invoked
C. executed
D. initialized
Answer optiona
Marks: 1
182 Standard which allows access to DBMS by Java client programs is classi
A. JCBD standard
B. JDBC standard
C. BDJC standard
D. CJBD standard
Answer optionb
Marks: 2
183 Which of the Following is NOT a valid Syntax for getConnection() Metho
A. public static Connection getConnection(String url)
B. public static Connection getConnection(String url, String userID, Stri
public static Connection getConnection(jdbc:<subprotocol>:<subname>Str
C. password)
D. None of the Above
Answer optiond
Marks: 1
In two-tier client/server architecture, running of application program
184 interface programs is in control of___________
A. modulation side
B. client side
C. server side
D. host side
Answer optionb
Marks: 2
185 Which of the following must be closed at end of Java program ?
A. Result
B. Connection
C. Query
D. Both A and B
Answer optionb
Marks: 1
186 A Java application program does not include declarations for
A. Data stored in database
B. Data retrieved of database
C. Data executed
D. Data manipulated
Answer optiona
Marks: 1
A label is a simple control which is used to display
187 _________________on the window
A. button
B. Editable Text
C. Non-Editable Text
D. All of above
Answer optionc
Marks: 1
Which statement is true with respect to the following code?
import java.awt.*;
import javax.swing.*;
public class Test
{
public static void main(String[] args)
{
188 JFrame frame = new JFrame("My Frame");
frame.getContentPane().add(new JButton("OK"));
frame.getContentPane().add(new JButton("Cancel"));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 200);
frame.setVisible(true);
}
}
A. Only button OK is displayed.
B. Only button Cancel is displayed.
Both button OK and button Cancel are displayed and button OK is displa
C. side of button OK.
Both button OK and button Cancel are displayed and button OK is displa
D. side
Answer optionb
Marks: 2
189 Label is ___________ entity.
A. Active
B. Passive
C. Both A& B
D. None of these
Answer optionb
Marks: 1
190 ___________ method is used to set or change the text in a Label.
A. setText(String strLabel)
B. getText()
C. getAlignment()
D. None of these
Answer optiona
Marks: 1
191 getAlignment() is the method of ________ class.
A. Button
B. List
C. Choice
D. Label
Answer optiond
Marks: 1
Label(String str) creates a label that contains the string specified b
192 _________
A. Right-Justified
B. Left-Justified
C. Center-Justifed
D. All of above
Answer optionb
Marks: 1
193 Which of the following Statement is NOT true for Type-2 Drivers
A. Driver needs to be installed separately in individual client machines
B. The Vendor client library needs to be installed on client machine.
C. Type-2 driver isn't written in java, that's why it isn't a portable dr
D. None of the Above
Answer optiond
Marks: 1
194 Which of the following method is used to set Label for Button B
A. B.setLabel(String S)
B. B.getLabel()
C. Both A& B
D. B.setText(String S)
Answer optiona
Marks: 1
With respect to Type-3 drivers
A)Type-3 drivers are fully written in Java, hence they are portable dr
195 B)No client side library is required because of application server tha
tasks like auditing, load balancing, logging etc.
A. A is True But B is False
B. B is True But A is False
C. Both are False
D. Both are True
Answer optiond
Marks: 1
196 The various controls supported by AWT are
A. Buttons,Scrollbar
B. Label,TabbedPanes
C. Tress,Tables
D. All of above
Answer optiona
Marks: 1
197 Which of the following is NOT true for Type - 4 drivers
A. Type-4 driver is also called native protocol driver.
B. Different driver is not needed for different database.
C. No client-side or server-side installation required.
D. It is fully written in Java language, hence they are portable drivers.
Answer optionb
Marks: 1
198 Which method does return true value if specified address is a multicas
A. isMulticastHostName()
B. isMulticastHostAddress()
C. isMulticastAddress()
D. isMulticastIPAddress()
Answer optionc
Marks: 1
199 InetAddress has two subclasses called as:
A. IPV4Address() and IPV6Address()
B. IP4VAddress() and IP6VAddress()
C. Inet4Address() and Inet6Address()
D. InetAddress4() and InetAddress6()
Answer optionc
Marks: 1
What is output of following code?
import java.net.*;
200 class Inet{
public static void main(String arg[]){
InetAddress ip=InetAddress.getLocalHost();
System.out.println(ip.getHostAddress();
}}
A. 192.168.0.100
B. localhost/192.168.0.100
C. localhost machine
D. localhost//8080:
Answer optionc
Marks: 2
what is the output of following program
import java.net.*;
class Demo
{
public static void main(String arg[]) throws UnKnownHostException
{
201 InetAddress ipa=InetAddress.getLocalHost();
InetAddress ipa1=InetAddress.getLocalHost("www.google.com");
boolean b=ipa.equals(ipa1);
System.out.println(b);
}
}
A. true
B. false
C. compile time error
D. 0
Answer optionc
Marks: 1
what is the output of following program
import java.net.*;
class Demo
{
public static void main(String arg[]) throws UnKnownHostException
{
202 InetAddress ipa=InetAddress.getLocalHost();
InetAddress ipa1=InetAddress.getLocalHost();
boolean b=ipa.equals(ipa1);
System.out.println(b);
}
}
A. true
B. false
C. 0
D. 1
Answer optiona
Marks: 2
203 InetAddress class is used to encapsulate both numerical IP address and
A. port number
B. host name
C. server name
D. socket name
Answer optionb
Marks: 1
what is the output of following program
import java.net.*;
class Demo
{
public static void main(String arg[]) throws UnKnownHostException
204 {
InetAddress ipa=InetAddress.getByName("www.google.com");
System.out.println(ipa.getHostName());
}
}
A. www.google.com
B. www.google.com/217.196.214.99
C. 217.196.214.99
D. None of the above
Answer optiona
Marks: 2
You can simply use InetAddress class when working with IP address beca
205 accommodate both ___________ styles.
A. IP4V and IP6V
B. IPV4 and IPV6
C. host name and IP
D. A and B
Answer optionb
Marks: 1
206 What does getHostAddress() of InetAddress class terurn?
A. Returns host address with ipaddress.
B. Returns a string that represents ipaddresses with hostname.
C. Returns a string that represents a host address associated with the In
D. Returns a string that represents a host name associated with Inetaddr
Answer optionc
Marks: 1
207 getHostName() of InetAddress class is used to_______
A. Return a string that represents host name associated with Inetaddress
B. Return a string that represents host address associated with Inetaddre
C. Return an object that represents Ipaddress associated with host name
D. Return Ipaddress that is associated with InetAddress object .
Answer optiona
Marks: 1
208 Which of the following statement is correct ?
A. There are two kinds of sockets in java one is for server and other for
B. There is only one socket for server.
C. There is only one socket for client.
D. There is only one socket for server as well as for client.
Answer optiona
Marks: 1
209 Which of the following class is used to create server that listen for
A. httpserver
B. ServerSocket
C. DatagramSocket
D. Socket
Answer optionb
Marks: 1
210 What happens if server socket is not able to listen on specified port
A. The system exits gracefully with appropriate message
B. The system will wait till port is free.
C. IoExeption is thrown when opening the socket
D. PortOccupiedException is thrown.
Answer optionc
Marks: 1
Which exception will be thrown if client socket does not specify the h
211 created ?
A. IOException
B. UnknownHostException
C. UnknownHostNameException
D. UnknownPortException
Answer optionb
Marks: 1
Which constructor will you use to create client socket using a preexsi
212 object and a port ?
A. Socket (String hostname, int port )
B. Socket (Inetaddress ipAdd, int port )
C. Socket (Inetaddress ip Add, string Hostname)
D. Socket ( int port, Inetaddress ipAdd )
Answer optionb
Marks: 1
213 __________method returns the local part to which the invoking socket o
A. int getLocalHost()
B. int getLocalPort()
C. int getPort()
D. int GetLocalHost()
Answer optiona
Marks: 1
214 Which of the following are factory methods of InetAddress class?
A. static InetAddress[] getAllByName(String hostname)
B. static InetAddres getLocalHost()
C. string getHostName()
D. A and B
Answer optiond
Marks: 1
215 Which of the following methods belong to ServerSocket class
A. accept()
B. connect()
C. bind()
D. A and C
Answer optiond
Marks: 1
216 ServerSocket class has one of the following constructor
A. ServerSocket(int port)
B. ServerSocket(String host, int port)
C. ServerSocket(int port, InetAddress add)
D. ServerSocket(InetAddress add, int port)
Answer optiona
Marks: 1
Socket method called______returns the port number that socket is bound
217 machine
A. int getLocalPortt()
B. int getPort()
C. InetAddress getInetAddress()
D. string getHostAddress()
Answer optionb
Marks: 1
218 What are different factory methods of InetAddress class?
A. getByName()
B. GetLocalHost()
C. getByAddress()
D. both A & C
Answer optiond
Marks: 1
How long is an IPv6 address?
219
A. 32 bits
B. 128 bytes
C. 64 bits
D. 128 bits
Answer optiond
Marks: 1
__________________method is needed only when you instantiate the socke
220 argument constructer.
A. bind()
B. connect()
C. accept()
D. SetHostName()
Answer optionb
Marks: 1
InetAddress class having method which returns a string that shows the
221 address.
A. toString()
B. getHostAddress()
C. getLocalHost()
D. none of the above
Answer optiona
Marks: 1
If server socket is created using serversocket () constructer then whi
222 use to bind the serve socket ?
A. isbind()
B. bind()
C. bind To()
D. bind ( socketAddress host , int backlog)
Answer optiond
Marks: 1
223 accept method is used for _______________________
A. Incoming Client connection
B. Incoming Server socket
C. Accepting request from server
D. Waiting socket
Answer optiona
Marks: 1
_____________Class represents the socket that both the client & server
224 with each other
A. java.net.Serversocket
B. java.net.Server
C. Java.net.socket
D. java.net.Clientsocket
Answer optionc
Marks: 1
225 Socket s1= Socket ( localhost, 1346), What does it means ?
A. Client socket is waiting for connection
B. Client socket is created to connect with specified host name and port
C. Client socket is name as localhost and Port number is 1346
D. server socket is connected to local host with port number 1346
Answer optionb
Marks: 1
What is the output of following statements
Socket s1=new Socket("localhost",1234);
226 int a=s1.getPort();
System.out.println(a);
A. localhost
B. localhost/1234
C. 1234
D. 1234/localhost
Answer optionc
Marks: 2
227 Correct way of using ServerSocket is___________
A. ServerSocket(int port)
B. ServerSocket(int port,int maxQueue)
C. ServerSocket(int port,int maxQueue,InetAddress localAddress)
D. All of the above
Answer optiond
Marks: 1
What is the output of following statements?
ServerSocket ss=new ServerSocket(1349);
228 Socket s1=ss.accept();
System.out.println(ss.getLocalPort());
A. port number of client socket
B. 1349
C. local port
D. None of the above
Answer optionb
Marks: 1
229 public InputStream getInputStream() is method of ____________ class
A. Serversocket
B. ClientSocket
C. Socket
D. All of the above
Answer optionc
Marks: 1
230 getOutputStream() returns the output stream of the ________
A. Socket
B. ServerSocket
C. ClientSocket
D. None of the above
Answer optiona
Marks: 1
231 Which of the following statement is correct?
A. The input stream of socket is connected to the output stream of remote
B. The output stream of socket is connected to the input stream of remote
C. The output stream of socket is connected to the output stream of remot
D. A and B
Answer optiond
Marks: 1
232 __________method makes socket object no longer capable of connecting a
A. send()
B. wait()
C. connect()
D. close()
Answer optiond
Marks: 1
If your application has successfully bound to specified port and is re
233 request then_________
A. an exception is thrown
B. an IOException is thrown
C. it does not throw an exception
D. UnknownHostException is thrown
Answer optionc
Marks: 1
234 Socket is the combination of ______________ and __________.
A. IP address and port number
B. port number and local host
C. IPAddress and machine number
D. All of the above
Answer optiona
Marks: 1
235 Which steps occur when establishing a TCP connection between two compu
A. The server initiates a ServerSocket object denoting port number to be
The server invokes the accept() method of ServerSocket class. This met
B. client connects to the server on the given port
After the server is waiting, a client instantiates a socket object wit
C. name and port number
D. All of the above
Answer optiond
Marks: 1
What is the output of the following statement?
ServerSocket ss=new ServerSocket(1234);
236 Socket s1=ss.accept();
System.out.println(s1.getPort());
A. port number of client socket
B. 1234
C. local port
D. All of the above
Answer optiona
Marks: 2
What is the output of following statement?
ServerSocket ss=new ServerSocket(1234);
237 Socket s1=ss.accept();
System.out.println(s1.getRemoteSocketAddress());
A. 1234
B. iPAddress of serversocket
C. IPAddress of client with port number
D. IPAddress of server with port number
Answer optionc
Marks: 1
What is the output of following statement?
238 Socket s1=new Socket("localhost",1234);
System.out.println(s1.getRemoteSocketAddress());
A. IPAddress of client with port number
B. host name, IPAddress and port number of Serversocket
C. host name and IPAddress Serversocket
D. IPAddress of server with port number
Answer optionb
Marks: 1
239 Connection timed out exception is occurred _________
A. if client socket is not created
B. if serversocket does not accept client request
C. if port number is not available which is specified by client socket wi
D. None of the above
Answer optionc
Marks: 1
Which method is used to expose the details of establishing connection
240 socket & client socket ?
A. connect()
B. receive()
C. there is no such method
D. None of the above
Answer optionc
Marks: 1
You can gain access to the input and output streams associated with so
241 getInputStream()
A. getOutStream()
B. setOutputStream()
C. getOutputStream()
D. getOutputClass()
Answer optionc
Marks: 1
Which exception will occur when port is already bound with an applicat
242 application is requesting for same port?
A. IOException
B. PortNotFoundException
C. UnknownPortNameException
D. ConectException
Answer optiona
Marks: 1
When you will use this ServerSocket(int port, int que) constructor to
243 socket
A. to create ServerSocket with port number
B. to create ServerSocket with port number & Ip address
C. to create ServerSocket with port number and number of incoming client
D. B & C
Answer optionc
Marks: 1
Socket(InetAddress host, int port) in this constructor, what does firs
244 for ?
A. host name
B. host name and IPAddress specified by InetAddress object
C. IpAddress of host
D. ipaddress and port number
Answer optionb
Marks: 1
Which constructor will you use to connect to specified host and port b
245 on the local host at specified address & port
A. Socket()
B. Socket(String host, int port)
C. Socket (Inetaddress ipAdd,int port)
D. Socket ( String host,int port, Inetaddress ipAdd, int localport )
Answer optiond
Marks: 1
246 Which of the following class is used to create client socket
A. httpserver
B. Datagram Socket
C. Socket
D. ClientSocket
Answer optionc
Marks: 1
What will be the output of following statements
247 Socket s1=Socket("localhost",1349);
System.out.println(s1.getLocalPort());
A. 1349
B. port number of local machine
C. local host
D. localhost/1349
Answer optionb
Marks: 2
248 Which of the following are Instance method of InetAddress Class
A. byte[] getAddress()
B. string getHostName()
C. A and B
D. static InetAddress getByName(string hostname)
Answer optionc
Marks: 1
Which constructor of DatagramSocket class is used to create a datagram
249 it with the given port number?
A. DatagramSocket(int port)
B. DatagramSoclet(int port InetAddress add)
C. DatagramSoclet()
D. None of the above
Answer optiona
Marks: 1
250 Which class is used for connection-less socket programming ?
A. DatagramSoclet
B. DatagramServer
C. A and B
D. None of the above
Answer optiona
Marks: 1
251 Which exception will occur if specified port number is not available f
A. UnknownException
B. SocketException
C. UnknownSocketException
D. UnknownPortException
Answer optionb
Marks: 1
Which of the following constructor is used to create datagram socket w
252 host address
A. DatagramSoclet(int port)
B. DatagramSoclet(int port InetAddress add)
C. DatagramSoclet()
D. A & B
Answer optionb
Marks: 1
253 Which constructor will you use to send packet?
A. DatagramPacket(byte[] bar, int len)
B. DatagramPacket(byte[] bar, int len, int port)
C. DatagramPacket(string s1, int len, InetAddress, int port)
D. All of the above
Answer optionb
Marks: 1
Java DatagramSocket and DatagramPacket classes are used for __________
254 programming
A. Connection-oriented
B. Connection-less
C. A & B
D. Reliable
Answer optionb
Marks: 1
255 Datagram Packet is a message than can be used for _________ messages
A. Connection-oriented or connection less
B. send and store
C. send and receive
D. receive and read
Answer optionc
Marks: 1
256 Which constructors are used to receive data from packet?
A. DatagramPacket(byte[] bar, int len)
B. DatagramPacket(byte[] bar, int off, int len)
C. DatagramPacket(string s1, int len, InetAddress, int port)
D. A and B
Answer optiond
Marks: 1
257 getData() & getLenght() are the methods of ___________ class
A. DatagramSoclet
B. ServerSocket
C. DatagramPacket
D. ClientSocket
Answer optionc
Marks: 1
What is the output of following code?
258 DatagramPacket dp =new DatagramPacket(byte[] data, 1024);
System.out.println(dp.getLength());
A. 1024
B. data, 1024
C. 1024, data
D. Null
Answer optiona
Marks: 2
259 Find the correct code from following program for given output
import java.awt.*;
import javax.swing.*;
/* <applet code="
JLabelDemo" width=250 height=150> </applet> */ public class JLabelDemo
A. public void init()
{
Container contentPane = getContentPane();
ImageIcon ii = new ImageIcon("IC.jpg");
JLabel jl = new JLabel("IC", ii, JLabel.CENTER); contentPane.add(jl);
} }
import java.awt.*;
import javax.swing.*;
/* <applet code="JLabelDemo" width=250 height=150> </applet> */
B. public class JLabelDemo extends JApplet { public void init() { Cont
getContentPane();
ImageIcon ii = new ImageIcon("IC.jpg"); JLabel jl = new JLabel("IC",
} }
import java.awt.*;
import javax.swing.*;
/* <applet code="JLabelDemo" width=250 height=150> </applet> */
public class JLabelDemo extends JApplet
{
C. public void init()
{
ImageIcon ii = new ImageIcon("IC.jpg");
JLabel jl = new JLabel("IC", ii, JLabel.CENTER); contentPane.add(jl);
} }
/* <applet code="JLabelDemo" width=250 height=150> </applet> */ publi
extends JApplet { public void init() { Container contentPane = getC
D. ImageIcon ii = new ImageIcon("IC.jpg"); JLabel jl = new JLabel("IC",
contentPane.add(jl); } }
Answer optiona
Marks: 2
Consider the following code and state the missing code.
import java.sql.*;
class Example1{
public static void main(String args[]){
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
260 Connection
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe",
PreparedStatement stmt=con.prepareStatement("insert into Emp values(?,
----------------------------------------------
int i=stmt.executeUpdate();
con.close();
}catch(Exception e){ System.out.println(e);}
}
}
A. stmt.setInt(1,101); stmt.setString(2,"Ratan"); stmt.setString(2,50
B. stmt.setInt(1,101); stmt.setString(2,"Ratan"); stmt.setInt(3,50000
C. stmt.setInt(1,101); stmt.setString(2,2); stmt.setInt(3,50000);
D. stmt.setInt(101); stmt.setString(2,2); stmt.setInt(3,50000);
Answer optionb
Marks: 2
261 Choose the correct code to display the following output.
import javax.swing.*; /* <applet code="JCheckBoxDemo" width=400 height
public class JCheckBoxDemo extends JApplet implements ItemListener { J
public void init() { Container contentPane = getContentPane(); content
FlowLayout()); JCheckBox cb = new JCheckBox("C", true); cb.addItemList
contentPane.add(cb); cb = new JCheckBox("C++", false); cb.addItemListe
A. contentPane.add(cb); cb = new JCheckBox("Java", false); cb.addItemList
contentPane.add(cb); cb = new JCheckBox("Perl", false); cb.addItemList
contentPane.add(cb); jtf = new JTextField(15); contentPane.add(jtf); }
itemStateChanged(ItemEvent ie) { JCheckBox cb = (JCheckBox)ie.getItem(
jtf.setText(cb.getText()); } }
import java.awt.*; import java.awt.event.*; import javax.swing.*; /*cl
extends JApplet implements ItemListener { JTextField jtf; public void
contentPane = getContentPane(); contentPane.setLayout(new FlowLayout()
new JCheckBox("C", true); cb.addItemListener(this); contentPane.add(cb
B. JCheckBox("C++", false); cb.addItemListener(this); contentPane.add(cb)
JCheckBox("Java", false); cb.addItemListener(this); contentPane.add(cb
JCheckBox("Perl", false); cb.addItemListener(this); contentPane.add(cb
JTextField(15); contentPane.add(jtf); } public void itemStateChanged(I
JCheckBox cb = (JCheckBox)ie.getItem(); jtf.setText(cb.getText()); } }
import java.awt.*; import java.awt.event.*; import javax.swing.*; /* <
code="JCheckBoxDemo" width=400 height=50> </applet> */ public class JC
JApplet implements ItemListener { JTextField jtf; public void init() {
contentPane = getContentPane(); contentPane.setLayout(new FlowLayout()
new JCheckBox("C", true); cb.addItemListener(this); contentPane.add(cb
C. JCheckBox("C++", false); cb.addItemListener(this); contentPane.add(cb)
JCheckBox("Java", false); cb.addItemListener(this); contentPane.add(cb
JCheckBox("Perl", false); cb.addItemListener(this); contentPane.add(cb
JTextField(15); contentPane.add(jtf); } public void itemStateChanged(I
JCheckBox cb = (JCheckBox)ie.getItem(); jtf.setText(cb.getText()); } }
import java.awt.*; import java.awt.event.*; import javax.swing.*; /* <
code="JCheckBoxDemo" width=400 height=50> </applet> */ public class JC
JApplet implements ItemListener { JTextField jtf; public void init() {
contentPane.add(cb); cb = new JCheckBox("C++", false); cb.addItemListe
D. contentPane.add(cb); cb = new JCheckBox("Java", false); cb.addItemList
contentPane.add(cb); cb = new JCheckBox("Perl", false); cb.addItemList
contentPane.add(cb); jtf = new JTextField(15); contentPane.add(jtf); }
itemStateChanged(ItemEvent ie) { JCheckBox cb = (JCheckBox)ie.getItem(
jtf.setText(cb.getText()); } }
Answer optionc
Marks: 2
262 Choose the correct code to display the following output.
import javax.swing.*; /* <applet code="JButtonDemo" width=250 height=
public class JButtonDemo extends JApplet implements ActionListener { J
public void init() { Container contentPane = getContentPane(); content
FlowLayout()); ImageIcon france = new ImageIcon("green.jpg"); JButton
JButton(france); jb.setActionCommand("Green"); jb.addActionListener(th
contentPane.add(jb); ImageIcon germany = new ImageIcon("red.jpg"); jb
A. JButton(germany); jb.setActionCommand("Red"); jb.addActionListener(thi
contentPane.add(jb); ImageIcon italy = new ImageIcon("yellow.jpg"); jb
JButton(italy); jb.setActionCommand("Yellow"); jb.addActionListener(th
contentPane.add(jb); ImageIcon japan = new ImageIcon("black.jpg"); jb
JButton(japan); jb.setActionCommand("Black"); jb.addActionListener(thi
contentPane.add(jb); jtf = new JTextField(15); contentPane.add(jtf); }
actionPerformed(ActionEvent ae) { jtf.setText(ae.getActionCommand());
import java.awt.*; import java.awt.event.*; import javax.swing.*; /* <
B. code="JButtonDemo" width=250 height=300> </applet> */ public class JBu
JApplet implements ActionListener { JTextField jtf; public void init()
contentPane = getContentPane(); contentPane.setLayout(new FlowLayout()
= new ImageIcon("green.jpg"); JButton jb = new JButton(france);
jb.setActionCommand("Green"); jb.addActionListener(this); contentPane.
germany = new ImageIcon("red.jpg"); jb = new JButton(germany);
jb.setActionCommand("Red"); jb.addActionListener(this); contentPane.ad
italy = new ImageIcon("yellow.jpg"); jb = new JButton(italy);
jb.setActionCommand("Yellow"); jb.addActionListener(this); contentPane
japan = new ImageIcon("black.jpg"); jb = new JButton(japan);
jb.setActionCommand("Black"); jb.addActionListener(this); contentPane.
JTextField(15); contentPane.add(jtf); } public void actionPerformed(Ac
}
import java.awt.*; import java.awt.event.*; import javax.swing.*; /* <
code="JButtonDemo" width=250 height=300> </applet> */ public class JBu
JApplet implements ActionListener { JTextField jtf; public void init()
contentPane = getContentPane(); contentPane.setLayout(new FlowLayout()
= new ImageIcon("green.jpg"); JButton jb = new JButton(france);
jb.setActionCommand("Green"); jb.addActionListener(this); contentPane.
germany = new ImageIcon("red.jpg"); jb = new JButton(germany);
C. jb.setActionCommand("Red"); jb.addActionListener(this); contentPane.ad
italy = new ImageIcon("yellow.jpg"); jb = new JButton(italy);
jb.setActionCommand("Yellow"); jb.addActionListener(this); contentPane
japan = new ImageIcon("black.jpg"); jb = new JButton(japan);
jb.setActionCommand("Black"); jb.addActionListener(this); contentPane.
JTextField(15); contentPane.add(jtf); } public void actionPerformed(Ac
jtf.setText(ae.getActionCommand());
import java.awt.*; import java.awt.event.*; import javax.swing.*; /* <
code="JButtonDemo" width=250 height=300> </applet> */ public class JBu
JApplet implements ActionListener { JTextField jtf; public void init()
contentPane = getContentPane(); contentPane.setLayout(new FlowLayout()
= new ImageIcon("green.jpg"); JButton jb = new JButton(france);
jb.setActionCommand("Green"); jb.addActionListener(this); contentPane.
germany = new ImageIcon("red.jpg"); jb = new JButton(germany);
D. jb.setActionCommand("Red"); jb.addActionListener(this); contentPane.ad
italy = new ImageIcon("yellow.jpg"); jb = new JButton(italy);
jb.setActionCommand("Yellow"); jb.addActionListener(this); contentPane
japan = new ImageIcon("black.jpg"); jb = new JButton(japan);
jb.setActionCommand("Black"); jb.addActionListener(this); contentPane.
JTextField(15); contentPane.add(jtf); } public void actionPerformed(Ac
jtf.setText(ae.getActionCommand()); } }
Answer optiond
Marks: 2
Choose the correct code to display the following output.
263
import java.awt.*; import java.awt.event.*; import javax.swing.*; /* <
code="JCheckBoxDemo" width=400 height=50> </applet> */ public class JC
JApplet implements ItemListener { JTextField jtf; public void init() {
contentPane = getContentPane(); contentPane.setLayout(new FlowLayout()
new JCheckBox("C", true); cb.addItemListener(this); contentPane.add(cb
A. JCheckBox("C++", false); cb.addItemListener(this); contentPane.add(cb)
JCheckBox("Java", false); cb.addItemListener(this); contentPane.add(cb
JCheckBox("Perl", false); cb.addItemListener(this); contentPane.add(cb
JTextField(15); contentPane.add(jtf); } public void itemStateChanged(I
JCheckBox cb = (JCheckBox)ie.getItem(); jtf.setText(cb.getText()); } }
import javax.swing.*; /* <applet code="JCheckBoxDemo" width=400 heigh
public class JCheckBoxDemo extends JApplet implements ItemListener { J
public void init() { Container contentPane = getContentPane(); content
FlowLayout()); JCheckBox cb = new JCheckBox("C", true); cb.addItemList
contentPane.add(cb); cb = new JCheckBox("C++", false); cb.addItemListe
B. contentPane.add(cb); cb = new JCheckBox("Java", false); cb.addItemList
contentPane.add(cb); cb = new JCheckBox("Perl", false); cb.addItemList
contentPane.add(cb); jtf = new JTextField(15); contentPane.add(jtf); }
itemStateChanged(ItemEvent ie) { JCheckBox cb = (JCheckBox)ie.getItem(
jtf.setText(cb.getText()); } }
import java.awt.*; import java.awt.event.*; import javax.swing.*; /* <
code="JCheckBoxDemo" width=400 height=50> </applet> */ public class JC
JApplet implements ItemListener { JTextField jtf; public void init() {
contentPane = getContentPane(); contentPane.setLayout(new FlowLayout()
new JCheckBox("C", true); cb.addItemListener(this); contentPane.add(cb
C. JCheckBox("C++", false); cb.addItemListener(this); contentPane.add(cb)
JCheckBox("Java", false); cb.addItemListener(this); contentPane.add(cb
JCheckBox("Perl", false); cb.addItemListener(this); contentPane.add(cb
JTextField(15); contentPane.add(jtf); } public void itemStateChanged(I
JCheckBox cb = (JCheckBox)ie.getItem(); } }
import java.awt.*; import java.awt.event.*; import javax.swing.*; /* <
code="JCheckBoxDemo" width=400 height=50> </applet> */ public class JC
D. JApplet implements ItemListener { JTextField jtf; public void init() {
contentPane = getContentPane(); contentPane.setLayout(new FlowLayout()
new JCheckBox("C", true); cb.addItemListener(this); contentPane.add(cb
JCheckBox("C++", false); cb.addItemListener(this); contentPane.add(cb)
JCheckBox("Java", false); cb.addItemListener(this); contentPane.add(cb
JCheckBox("Perl", false); cb.addItemListener(this); contentPane.add(cb
JTextField(15); contentPane.add(jtf); } public void itemStateChanged(I
JCheckBox cb = (JCheckBox)ie.getItem(); jtf.setText(cb.getText());
Answer optiona
Marks: 2
264 Choose the correct code to display the following output.
import java.awt.*; import java.awt.event.*; import javax.swing.*; /* <
code="JComboBoxDemo" width=300 height=100> </applet> */ public class J
extends JApplet implements ItemListener { JLabel jl; ImageIcon green,
public void init() { Container contentPane = getContentPane(); content
A. FlowLayout()); JComboBox jc = new JComboBox(); jc.addItem("Green"); jc
jc.addItem("Black"); jc.addItem("Yellow"); jc.addItemListener(this); c
jl = new JLabel(new ImageIcon("green.jpg")); contentPane.add(jl); } pu
itemStateChanged(ItemEvent ie) { String s = (String)ie.getItem(); jl.s
ImageIcon(s + ".jpg")); } }
import javax.swing.*; /* <applet code="JComboBoxDemo" width=300 heigh
public class JComboBoxDemo extends JApplet implements ItemListener { J
green, red, black, yellow; public void init() { Container contentPane
contentPane.setLayout(new FlowLayout()); JComboBox jc = new JComboBox(
B. jc.addItem("Green"); jc.addItem("Red"); jc.addItem("Black"); jc.addIte
jc.addItemListener(this); contentPane.add(jc); jl = new JLabel(new
ImageIcon("green.jpg")); contentPane.add(jl); } public void itemStateC
ie) { String s = (String)ie.getItem(); jl.setIcon(new ImageIcon(s + ".
import java.awt.*; import java.awt.event.*; import javax.swing.*; /* <
code="JComboBoxDemo" width=300 height=100> </applet> */ public class J
extends JApplet implements ItemListener { JLabel jl; ImageIcon green,
public void init() { contentPane.setLayout(new FlowLayout()); JComboB
C. JComboBox(); jc.addItem("Green"); jc.addItem("Red"); jc.addItem("Black
jc.addItem("Yellow"); jc.addItemListener(this); contentPane.add(jc); j
ImageIcon("green.jpg")); contentPane.add(jl); } public void itemStateC
ie) { String s = (String)ie.getItem(); jl.setIcon(new ImageIcon(s + ".
import java.awt.*; import java.awt.event.*; import javax.swing.*; /* <
D. code="JComboBoxDemo" width=300 height=100> </applet> */ public class J
extends JApplet implements ItemListener { JLabel jl; ImageIcon green,
public void init() { Container contentPane = getContentPane(); content
FlowLayout()); JComboBox jc = new JComboBox(); jc.addItem("Green"); jc
jc.addItem("Black"); jc.addItem("Yellow"); jc.addItemListener(this); c
jl = new JLabel(new ImageIcon("green.jpg")); public void itemStateCha
{ String s = (String)ie.getItem(); jl.setIcon(new ImageIcon(s + ".jpg"
Answer optiona
Marks: 2
265 Choose the correct code to display the following output.
import java.awt.*; import javax.swing.*; /* <applet code="JScrollPaneD
height=250> </applet> */ public class JScrollPaneDemo extends JApplet
init() { Container contentPane = getContentPane(); contentPane.setLayo
BorderLayout()); JPanel jp = new JPanel(); jp.setLayout(new GridLayout
A. 0; for(int i = 0; i < 20; i++) { for(int j = 0; j < 20; j++) { jp.add(
" + b)); ++b; } } int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NE
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp =
v, h); contentPane.add(jsp, BorderLayout.CENTER); }}
/* <applet code="JScrollPaneDemo" width=300 height=250> </applet> */ p
JScrollPaneDemo extends JApplet { public void init() { Container conte
getContentPane(); contentPane.setLayout(new BorderLayout()); JPanel jp
jp.setLayout(new GridLayout(20, 20)); int b = 0; for(int i = 0; i < 20
B. = 0; j < 20; j++) { jp.add(new JButton("Button " + b)); ++b; } } int v
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp =
v, h); contentPane.add(jsp, BorderLayout.CENTER); }
import java.awt.*; import javax.swing.*; /* <applet code="JScrollPaneD
height=250> </applet> */ public class JScrollPaneDemo extends JApplet
init() { Container contentPane = getContentPane(); contentPane.setLayo
BorderLayout()) JPanel jp = new JPanel(); jp.setLayout(new GridLayout(
C. 0; for(int i = 0; i < 20; i++) { for(int j = 0; j < 20; j++) { } int v
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp =
v, h); contentPane.add(jsp, BorderLayout.CENTER); }
import java.awt.*; import javax.swing/* <applet code="JScrollPaneDemo"
D. height=250> </applet> */ public class JScrollPaneDemo extends JApplet
init() { Container contentPane = getContentPane(); contentPane.setLayo
BorderLayout()); JPanel jp = new JPanel(); jp.setLayout(new GridLayout
0; for(int i = 0; i < 20; i++) { for(int j = 0; j < 20; j++) { jp.add(
" + b)); ++b; } } int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NE
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp =
v, h); contentPane.add(jsp, BorderLayout.CENTER); }
Answer optiona
Marks: 2
266 Which of the following are ways to create a Frame?
A. By creating the object of Frame class (association)
B. By extending Frame class (inheritance)
C. a and b
D. none of these
Answer optionc
Marks: 1
Choose the correct code to display the following output.
267
import java.awt.*;import java.awt.event.*;import javax.swing.*;import
/*<applet code="JTreeEvents" width=400 height=200></applet>*/ public c
extends JApplet {JTree tree;JTextField jtf; public void init() { // Ge
Container contentPane = getContentPane();// Set layout manager content
BorderLayout());// Create top node of tree DefaultMutableTreeNode top
A. DefaultMutableTreeNode("Options");// Create subtree of "A" DefaultMuta
DefaultMutableTreeNode("A"); top.add(a); DefaultMutableTreeNode a1 = n
DefaultMutableTreeNode("A1"); a.add(a1); DefaultMutableTreeNode a2 = n
DefaultMutableTreeNode("A2"); a.add(a2);// Create subtree of "B" Defau
b=new DefaultMutableTreeNode("B"); top.add(b); DefaultMutableTreeNode
DefaultMutableTreeNode("B1"); b1 = new DefaultMutableTreeNode("B1");
DefaultMutableTreeNode b3 = new DefaultMutableTreeNode("B3"); b.add(b3
tree = new JTree(top);// Add tree to a scroll pane int v =
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp =
JScrollPane(tree, v, h);// Add scroll pane to the content pane content
BorderLayout.CENTER); // Add text field to applet jtf = new JTextField
contentPane.add(jtf, BorderLayout.SOUTH);// Anonymous inner class to h
tree.addMouseListener(new MouseAdapter() {public void mouseClicked(Mou
{doMouseClicked(me);}});} void doMouseClicked(MouseEvent me) {TreePath
tree.getPathForLocation(me.getX(), me.getY()); if(tp != null)jtf.setTe
else jtf.setText("");}}
import java.awt.*;import java.awt.event.*;import javax.swing.*;import
/*<applet code="JTreeEvents" width=400 height=200></applet>*/ public c
extends JApplet {JTree tree;JTextField jtf; public void init() { // Ge
Container contentPane = getContentPane();// Set layout manager content
BorderLayout());// Create top node of tree DefaultMutableTreeNode top
DefaultMutableTreeNode("Options");// Create subtree of "A" DefaultMuta
DefaultMutableTreeNode("A");top.add(a); DefaultMutableTreeNode a1 = ne
DefaultMutableTreeNode("A1"); a.add(a1);DefaultMutableTreeNode a2 = ne
DefaultMutableTreeNode("A2"); a.add(a2);// Create subtree of "B" Defau
b=new DefaultMutableTreeNode("B"); top.add(b);DefaultMutableTreeNode b
DefaultMutableTreeNode("B1"); b.add(b1);DefaultMutableTreeNode b2 = ne
B. DefaultMutableTreeNode("B2"); b.add(b2);DefaultMutableTreeNode b3 = ne
DefaultMutableTreeNode("B3"); b.add(b3);// Create tree tree = new JTre
to a scroll pane int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEE
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp =
JScrollPane(tree, v, h);// Add scroll pane to the content pane content
BorderLayout.CENTER); // Add text field to applet jtf = new JTextField
contentPane.add(jtf, BorderLayout.SOUTH);// Anonymous inner class to h
tree.addMouseListener(new MouseAdapter() {public void mouseClicked(Mou
{doMouseClicked(me);}});} void doMouseClicked(MouseEvent me) {TreePath
tree.getPathForLocation(me.getX(), me.getY()); if(tp != null)jtf.setTe
else jtf.setText("");}}
import java.awt.*;import java.awt.event.*;import javax.swing.*;import
/*<applet code="JTreeEvents" width=400 height=200></applet>*/ public c
extends JApplet {JTree tree;JTextField jtf; public void init() { // Ge
Container contentPane = getContentPane();// Set layout manager content
BorderLayout());// Create top node of tree DefaultMutableTreeNode top
C. DefaultMutableTreeNode("Options");// Create subtree of "A" DefaultMuta
DefaultMutableTreeNode("A"); top.add(a); DefaultMutableTreeNode a1 = n
DefaultMutableTreeNode("A1"); a.add(a1); // Create subtree of "B" Def
b=new DefaultMutableTreeNode("B"); top.add(b); DefaultMutableTreeNode
DefaultMutableTreeNode("B1"); b1 = new DefaultMutableTreeNode("B1");
DefaultMutableTreeNode b3 = new DefaultMutableTreeNode("B3"); b.add(b3
tree = new JTree(top);// Add tree to a scroll pane int v =
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp =
JScrollPane(tree, v, h);// Add scroll pane to the content pane content
BorderLayout.CENTER); // Add text field to applet jtf = new JTextField
contentPane.add(jtf, BorderLayout.SOUTH);// Anonymous inner class to h
tree.addMouseListener(new MouseAdapter() {public void mouseClicked(Mou
{doMouseClicked(me);}});} void doMouseClicked(MouseEvent me) {TreePath
tree.getPathForLocation(me.getX(), me.getY()); if(tp != null)jtf.setTe
else jtf.setText("");}}
import java.awt.*;import java.awt.event.*;import javax.swing.*;import
/*<applet code="JTreeEvents" width=400 height=200></applet>*/ public c
extends JApplet {JTree tree;JTextField jtf; public void init() { // Ge
Container contentPane = getContentPane();// Set layout manager content
BorderLayout());// Create top node of tree DefaultMutableTreeNode top
DefaultMutableTreeNode("Options");// Create subtree of "A" DefaultMuta
DefaultMutableTreeNode("A"); top.add(a); DefaultMutableTreeNode a1 = n
DefaultMutableTreeNode("A1"); a.add(a1); DefaultMutableTreeNode a2 = n
DefaultMutableTreeNode("A2"); a.add(a2); // Create subtree of "B" Defa
b=new DefaultMutableTreeNode("B"); top.add(b); DefaultMutableTreeNode
D. DefaultMutableTreeNode("B1"); b1 = new DefaultMutableTreeNode("B1");
new JTree(top);// Add tree to a scroll pane int v =
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp =
JScrollPane(tree, v, h);// Add scroll pane to the content pane content
BorderLayout.CENTER); // Add text field to applet jtf = new JTextField
contentPane.add(jtf, BorderLayout.SOUTH);// Anonymous inner class to h
tree.addMouseListener(new MouseAdapter() {public void mouseClicked(Mou
{doMouseClicked(me);}});} void doMouseClicked(MouseEvent me) {TreePath
tree.getPathForLocation(me.getX(), me.getY()); if(tp != null)jtf.setTe
else jtf.setText("");}}
Answer optionb
Marks: 2
268 Give the abbreviation of AWT?
A. Applet Windowing Toolkit
B. Abstract Windowing Toolkit
C. Absolute Windowing Toolkit
D. None of the above
Answer optionb
Marks: 1
269 Choose the correct code to display the following output.
import java.awt.*; import javax.swing.*; /* <applet code="JTableDemo"
height=200> </applet> */ public class JTableDemo extends JApplet { pub
Container contentPane = getContentPane(); contentPane.setLayout(new Bo
final String[] colHeads = { "Name", "Phone", "Fax" }; final Object[][]
"Pramod", "4567", "8675" }, { "Tausif", "7566", "5555" }, { "Nitin", "
"Amol", "7345", "9222" }, { "Vijai", "1237", "3333" }, { "Ranie", "565
A. "Mangesh", "5672", "2176" }, { "Suhail", "6741", "4244" }, { "Nilofer"
{ "Jinnie", "1134", "5332" }, { "Heena", "5689", "1212" }, { "Saurav",
{ "Raman", "6751", "1415" } }; JTable table = new JTable(data, colHead
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp =
JScrollPane(table, v, h); contentPane.add(jsp, BorderLayout.CENTER); }
import java.awt.*; import javax.swing.*; /* <applet code="JTableDemo"
height=200> </applet> */ public class JTableDemo extends JApplet { pub
Container contentPane = getContentPane(); contentPane.setLayout(new Bo
final String[] colHeads = { "Name", "Phone", "Fax" }; final Object[][]
"Pramod", "4567", "8675" }, { "Tausif", "7566", "5555" }, { "Nitin", "
"Amol", "7345", "9222" }, { "Vijai", "1237", "3333" }, { "Ranie", "565
B. "Mangesh", "5672", "2176" }, { "Suhail", "6741", "4244" }, { "Nilofer"
{ "Jinnie", "1134", "5332" }, { "Heena", "5689", "1212" }, { "Saurav",
{ "Raman", "6751", "1415" } }; JTable table = new JTable(data, colHead
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp =
JScrollPane(table, v, h); contentPane.add(jsp, BorderLayout.CENTER);
<applet code="JTableDemo" width=400 height=200> </applet> */ public c
C. extends JApplet { public void init() { Container contentPane = getCont
contentPane.setLayout(new BorderLayout()); final String[] colHeads = {
"Fax" }; final Object[][] data = { { "Pramod", "4567", "8675" }, { "Ta
"5555" }, { "Nitin", "5634", "5887" }, { "Amol", "7345", "9222" }, { "
"3333" }, { "Ranie", "5656", "3144" }, { "Mangesh", "5672", "2176" },
"4244" }, { "Nilofer", "9023", "5159" }, { "Jinnie", "1134", "5332" },
"1212" }, { "Saurav", "9030", "1313" }, { "Raman", "6751", "1415" } };
JTable(data, colHeads); int v = ScrollPaneConstants.VERTICAL_SCROLLBAR
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp =
JScrollPane(table, v, h); contentPane.add(jsp, BorderLayout.CENTER); }
import java.awt.*; import javax.swing.*; /* <applet code="JTableDemo"
height=200> </applet> */ public class JTableDemo extends JApplet { Con
= getContentPane(); contentPane.setLayout(new BorderLayout()); final S
{ "Name", "Phone", "Fax" }; final Object[][] data = { { "Pramod", "456
"Tausif", "7566", "5555" }, { "Nitin", "5634", "5887" }, { "Amol", "73
"Vijai", "1237", "3333" }, { "Ranie", "5656", "3144" }, { "Mangesh", "
D. "Suhail", "6741", "4244" }, { "Nilofer", "9023", "5159" }, { "Jinnie",
{ "Heena", "5689", "1212" }, { "Saurav", "9030", "1313" }, { "Raman",
JTable table = new JTable(data, colHeads); int v =
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp =
JScrollPane(table, v, h); contentPane.add(jsp, BorderLayout.CENTER); }
Answer optiona
Marks: 2
270 Which of the below are common network protocols?
A. TCP
B. UDP
C. TCP and UDP
D. FTP
Answer optionc
Marks: 1
271 Choose the following code for following output :
// java Program to create a simple JPanel add components to it import
import java.awt.*; import javax.swing.*; class solution extends JFra
JFrame static JFrame f; // JButton static JButton b,
label to diaplay text static JLabel l; // main class
main(String[] args) { // create a new frame to stor text
f = new JFrame("panel"); // create a label to display text
A. JLabel("panel label"); // create a new buttons b =
JButton("button1"); b1 = new JButton("button2"); b2
JButton("button3"); // create a panel to add buttons
JPanel(); // add buttons and textfield to panel p.
p.add(b1); p.add(b2); p.add(l); // setback
p.setBackground(Color.red); // add panel to frame
// set the size of frame f.setSize(300, 300); f.sh
// java Program to create a simple JPanel add components to it import
import java.awt.*; import javax.swing.*; class solution extends JFra
JFrame static JFrame f; // JButton static JButton b,
label to diaplay text static JLabel l; // main class
main(String[] args) { // create a new frame to stor text
f = new JFrame("panel"); // create a label to display text
B. JLabel("panel label"); // create a new buttons b =
JButton("button1"); b1 = new JButton("button2"); b2
JButton("button3"); // create a panel to add buttons
JPanel(); // add buttons and textfield to panel p.
p.add(b1); p.add(b2); p.setBackground(Color.re
add panel to frame f.add(p); // set the size of fra
f.setSize(300, 300); f.show(); } }
// java Program to create a simple JPanel add components to it import
import java.awt.*; import javax.swing.*; class solution extends JFra
JFrame static JFrame f; // JButton static JButton b,
label to diaplay text static JLabel l; // main class
main(String[] args) { // create a new frame to stor text
f = new JFrame("panel"); // create a label to display text
C. JLabel("panel label"); // create a new buttons b =
JButton("button1"); b1 = new JButton("button2"); b2
JButton("button3"); // create a panel to add buttons
JPanel(); // add buttons and textfield to panel p.
p.add(b1); p.add(b2); p.add(l); // setback
p.setBackground(Color.red); // add panel to frame
// set the size of frame } }
// java Program to create a simple JPanel add components to it import
import java.awt.*; import javax.swing.*; class solution extends JFra
JFrame static JFrame f; // JButton static JButton b,
label to diaplay text static JLabel l; // main class
main(String[] args) { // create a new frame to stor text
f = new JFrame("panel"); // create a label to display text
D. = new JButton("button2"); b2 = new JButton("button3");
panel to add buttons JPanel p = new JPanel(); // a
textfield to panel p.add(b); p.add(b1); p.ad
p.add(l); // setbackground of panel p.setBackgroun
// add panel to frame f.add(p); // set the size of
f.setSize(300, 300); f.show(); } }
Answer optiona
Marks: 2
272 Which of the following statement is used to establish connection with
Connection conn =
A. DriverManager.getConnection(jdbc:mysql://localhost:3306/booksdb,user,p
Connection conn = DriverManager.getConnected(jdbc:mysql://localhost:33
B. password);
Connection conn =
C. DriverManager.getConnection(jdbc:odbc:mysql://localhost:3306/booksdb,u
D. Connection conn = DriverManager.getConnection(localhost:3306/booksdb,u
Answer optiona
Marks: 1
273 Which class provides many methods for graphics programming?
A. javax.awt.graphics
B. java.Graphics
C. java.awt.Graphics
D. None of the above
Answer optionc
Marks: 1
274 How would you set the color of a graphics context called g to cyan?
A. g.setColor(Color.cyan);
B. g.setCurrentColor(cyan);
C. g.setColor("Color.cyan");
D. g.setColor(new Color(cyan));
Answer optiona
Marks: 1
275 Which of the following are passed as an argument to the paint( ) metho
A. A Canvas object
B. A Graphics object
C. An Image object
D. A paint object
Answer optionb
Marks: 1
Which of the following methods are invoked by the AWT to support paint
276 operations?
A. paint( )
B. repaint( )
C. draw( )
D. redraw( )
Answer optiona
Marks: 1
Which of the following classes have a paint( ) method?
a.Canvas
277 b.Image
c.Frame
d.Graphics
A. b and d
B. a and c
C. a and b
D. c and d
Answer optionb
Marks: 1
Which of the following are methods of the Graphics class?
a.drawRect( )
278 b. drawImage( )
c.drawPoint( )
d. drawString( )
A. a , b and c
B. a , c and d
C. b,c and d
D. a, b and d
Answer optiond
Marks: 1
Which of the following are true?
a.The AWT automatically causes a window to be repainted when a portio
been
minimized and then maximized.
b.The AWT automatically causes a window to be repainted when a portio
279 been
covered and then uncovered.
c.The AWT automatically causes a window to be repainted when applicat
changed.
d. The AWT does not support repainting operations.
A. a and b
B. a and d
C. b and c
D. a and c
Answer optiona
Marks: 1
Given the following code
import java.awt.*;
public class SetF extends Frame
{
public static void main(String argv[])
{
280 SetF s = new SetF();
s.setVisible(true);
}
}
How could you set the frame surface color to pink and set its width to
200 pixels?
A. s.setBackground(Color.pink); s.setSize(300,200);
B. s.setColor(PINK); s.setSize(200,300);
C. s.Background(pink); s.setSize(300,200);
D. s.color=Color.pink; s.Size(300,200);
Answer optiona
Marks: 2
281 PreparedStatement interface extends which interface?
A. Statement
B. CallableStatement
C. ResultSet
D. None of the above
Answer optiona
Marks: 1
Consider the following program. Find which statement contains error.
import java.awt.*;
import javax.swing.*;
public class Demo { public
static void main(String args[]) { JFrame f =new JFrame("Toggle Button
Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
282 Container c=f.getContentPane(); c.add(new
JToggleButton("North"),BorderLayout.NORTH); c.add(new
JToggleButton("North"),BorderLayout.EAST); c.add(new
JToggleButton("North"),BorderLayout.WEST); c.add(new
JToggleButton("North"),BorderLayout.SOUTH); c.add(new
JToggleButton("North"),BorderLayout.CENTER); f.setSize(300,300);
f.setVisible(true); } }
A. error
B. No Error
C. compile time error
D. Run time errror
Answer optionb
Marks: 2
Which of the following methods can be used to change the size of a jav
object?
283 (A) dimension()
(B) setSize()
(C) size()
(D) resize()
A. (A), (B), (C) and (D)
B. (A), (B) and (D)
C. (B), (C) and (D)
D. (B) and (D)
Answer optiond
Marks: 1
Consider the following program. Find correct output
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class BgColor extends JFrame implements ActionListener{
private JButton btn;
private JButton red,blue,green;
private JLabel label;
public BgColor()
284 {
red = new JButton("red");
red.addActionListener(this);
add(red);
green = new JButton("green");
green.addActionListener(this);
add(green);
blue = new JButton("blue");
blue.addActionListener(this);
add(blue);
setLayout(new FlowLayout());
setSize(700,700);
setTitle("Bit Life - Java program Buttons Clicked");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
label = new JLabel("what is happening ?");
add(label);
public static void main(String[] args)
{
new BgColor();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == btn)
{
label.setText("button clicked");
}
if (e.getSource() == red)
{
label.setText("red selected");
getContentPane().setBackground(Color.RED);
A.
B.
C.
D. All of the above
Answer optiond
Marks: 2
find out missing line in following code. Import java.awt.*;
285 import javax.swing.*;
public class demo2 extends JApplet {
________________________________
JRadioButton b1=new JRadioButton("Button1') ; JRadioButton b2=new
JRadioButton("Button2"); public void init() {
cp.add(b1);
cp.add(b2);
ButtonGroup bg=new ButtonGroup();
bg.add(b1);
bg.add(b2); } }
A. Container cp=getContentPane()
B. JRadioButton(
C. ButtonGroup bg=new ButtonGroup();
D. bg.add(b1);
Answer optiona
Marks: 2
Observe the following code
import java.awt.*; import java.applet.*;
import java.util.*; /* <applet code="BorderLayoutDemo" width=400
height=200> </applet> */ public class BorderLayoutDemo extends
Applet { public void init() { setLayout(new BorderLayout()); add(new
Button("This is across the top."), BorderLayout.NORTH); add(new
Label("The footer message might go here."), BorderLayout.SOUTH);
add(new Button("Right"), BorderLayout.EAST); add(new Button("Left"),
BorderLayout.WEST); String msg = "The reasonable man adapts " +
"himself to the world;
286 " + "the unreasonable one persists in " +
"trying to adapt the world to himself.
" + "Therefore all progress
depends " + "on the unreasonable man.
" + " - George Bernard
Shaw
"; add(new TextArea(msg), BorderLayout.CENTER); } } What
will be the output of the above program?
A. The output is obtained in Applet with BorderLayout placing button on e
The output is obtained in Applet with BorderLayout placing button on e
B. TextArea at center
C. The output is obtained in Applet south and TextArea at center
The output is obtained in Applet with BorderLayout placing button on
D. east,west,north,south and TextArea at center
Answer optiond
Marks: 2
Observe the following code import java.awt.*; import javax.swing.*; /*
<applet code="JTableDemo.class" width=400 height=500> </applet>
*/ public class JTableDemo extends JApplet { public void init() {
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout()); final String[] colHeads = {
"Name", "Phone", "Fax"}; final Object[][] data = { {"Prashant",
287 "12345","6789"}, {"Rupesh", "12345", "23456"} }; JTable table =
new JTable(data, colHeads); int v =
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS; JScrollPane
jsp = new JScrollPane(table, v, h); contentPane.add(jsp,
BorderLayout.CENTER); } }
The output is obtained in table with two rows and two columns with hor
A. vertical scrollbar
The output is obtained in table with two rows and three columns with h
B. vertical scrollbar
The output is obtained in table with three rows and three columns with
C. vertical scrollbar
The output is obtained in table with four rows and three columns with
D. vertical scrollbar
Answer optionb
Marks: 2
288 Which of the following is true about AWT and Swing Component?
A. AWT Components create a process where as Swing Component create a thre
B. AWT Components create a thread where as Swing Component create a proce
C. Both AWT and Swing Component create a process
D. Both AWT and Swing Component create a thread
Answer optiona
Marks: 1
289 Which of the following is not a constructor of JTree Class
A. JTree(Object obj[])
B. JTree(int x)
C. JTree(TreeNode tn)
D. JTree()
Answer optionb
Marks: 1
Observe the following program and point out which statement contains
290 error.
importjava.awt.*;
importjavax.swing.*
; /* <applet
code="JTableDemo" width=400 height=200> </applet> */
public class JTableDemo extends JApplet {
public void init() {
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
final String[] colHeads = { "emp_Name", "emp_id","emp_salary" };
final Object[][] data = { { "Ramesh", "111", "50000"},
{ "Sagar", "222", "52000" },
{ "Virag", "333", "40000" },
{ "Amit","444", "62000" },
{ "Anil", "555", "60000" }, };
JTable table = new JTable(data,colHeads );
int v =ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h =ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPanejsp = new JScrollPane(table,,h,v); contentPane.add(jsp,
BorderLayout.CENTER); } }
A. Error in statement in which JScrollPane is created
B. statement in which JScrollPane is Not created
C. No Error in statement in which JScrollPane is created
D. Error in statement in which JScrollPane is deleted
Answer optiona
Marks: 2
291 ............. method is used to execute CREATE Table query.
A. executeQuery()
B. executeUpdate()
C. execute()
D. All of the above
Answer optionb
Marks: 1
292 The setBackground() method is part of the following class in java.awt
A. Graphics
B. Component
C. Applet
D. Container
Answer optionb
Marks: 1
Find the missing statement in the following code
import java.awt.*;
import javax.swing.*;
/* <applet code="JLabelDemo" width=250 height=150> </applet> */
public class JLabelDemo extends JApplet
{
public void init()
293 {
Container contentPane = getContentPane();
ImageIcon ii = new ImageIcon("IC.jpg");
JLabel jl = new JLabel("IC", ii, JLabel.CENTER);
--------------------
}
}
A. setcontentPane.add(jl);
B. getcontentPane.add(jl);
C. contentPane.add(jl);
D. contentPane.add(j);
Answer optionc
Marks: 2
Find the missing statement in the following code
import java.awt.*;
import javax.swing.*;
/*
<applet code="JTextFieldDemo" width=300 height=50>
</applet>
*/
public class JTextFieldDemo extends JApplet
{
294 JTextField jtf;
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
_________________________________
contentPane.add(jtf);
}
}
A. jtf = new JTextField(15);
B. jtf = JTextField(15);
C. Both A & B
D. None Of the above
Answer optiona
Marks: 2
Which of the following classes are derived from the Container class. S
correct answers.
a. Component
295 b.Panel
c.Dialog
d.Frame
A. b ,c and d
B. a ,b and c
C. a and b
D. all of above
Answer optiona
Marks: 1
Find the missing statement in the following code
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/*
<applet code="JButtonDemo" width=250 height=300>
</applet>
*/
public class JButtonDemo extends JApplet
296 implements ActionListener
{
JTextField jtf;
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
ImageIcon france = new ImageIcon("green.jpg");
JButton jb = new JButton(france);
jb.setActionCommand("Green");
jb.addActionListener(this);
contentPane.add(jb);
ImageIcon germany = new ImageIcon("red.jpg");
jb = new JButton(germany);
jb.setActionCommand("Red");
jb.addActionListener(this);
contentPane.add(jb);
ImageIcon italy = new ImageIcon("yellow.jpg");
jb = new JButton(italy);
jb.setActionCommand("Yellow");
jb.addActionListener(this);
contentPane.add(jb);
ImageIcon japan = new ImageIcon("black.jpg");
jb = new JButton(japan);
jb.setActionCommand("Black");
jb.addActionListener(this);
contentPane.add(jb);
jtf = new JTextField(15);
contentPane.add(jtf);
}
public void actionPerformed(ActionEvent ae)
{
----------------------------------------
}
}
A. jtf.setText(ae.getActionCommand());
B. jtf.setText(ae.setActionCommand());
C. jtf.setText(ae.ActionCommand());
D. None of the above
Answer optiona
Marks: 2
Find the missing statement in the following code
import java.awt.*;
297 import java.awt.event.*;
import javax.swing.*;
/*
<applet code="JCheckBoxDemo" width=400 height=50>
</applet>
*/
public class JCheckBoxDemo extends JApplet
implements ItemListener
{
JTextField jtf;
public void init()
{
Container contentPane = getContentPane();
------------------------------------------------------------
JCheckBox cb = new JCheckBox("BLUE", true);
cb.addItemListener(this);
contentPane.add(cb);
cb = new JCheckBox("RED", false);
cb.addItemListener(this);
contentPane.add(cb);
cb = new JCheckBox("YELLOW", false);
cb.addItemListener(this);
contentPane.add(cb);
cb = new JCheckBox("GREEN", false);
cb.addItemListener(this);
contentPane.add(cb);
jtf = new JTextField(15);
contentPane.add(jtf);
}
public void itemStateChanged(ItemEvent ie)
{
JCheckBox cb = (JCheckBox)ie.getItem();
jtf.setText(cb.getText());
}
}
A. contentPane.setLayout(FlowLayout());
B. contentPane.Layout(new FlowLayout());
C. contentPane.getLayout(new FlowLayout());
D. contentPane.setLayout(new FlowLayout());
Answer optiond
Marks: 2
298 Find out the correct statement
A. public PreparedStatement prepareStatement(String query)throws IOExcept
B. private PreparedStatement preparedStatement(String query)throws IOExce
C. public PreparedStatement prepareStatement(String query)throws SQLExcep
D. protected PrepareStatement prepareStatement(String query)throws FileNo
Answer optionc
Marks: 1
Which of the following classes are derived from the Container class. S
answers.
a. Panel
299 b Window
c Frame
d Component
e Dialog
A. a,b,d,c
B. a, b, c, e
C. b, c,d,e
D. a, e,c,d
Answer optionb
Marks: 1
300 Which are the parameters of setString() method?
A. String value,String paramIndex
B. String paramIndex, String value
C. int paramIndex, int value
D. int paramIndex, String value
Answer optiond
Marks: 1
Name the class used to represent a GUI application window, which is op
301 and can have a title bar, an icon, and menus. Select the one correct a
A. Window
B. Panel
C. Dialog
D. Frame
Answer optiond
Marks: 1
302 What components will be needed to get following output?
A. . Label, TabbedPane, CheckBox
B. Panel, TabbedPane, List
C. TabbedPane, List, Applet
D. Applet, TabbedPane, Pane
Answer optionb
Marks: 2
303 What is the return type of executeQuery() method?
A. int
B. connection
C. ResultSet
D. None of the above
Answer optionc
Marks: 1
304 Button B1=new Button("Submit");Which method is used to obtain output a
A. setText()
B. setLabel()
C. getText()
D. getLabel()
Answer optiond
Marks: 1
305 Which of these package contains classes and interfaces for networking?
A. java.io
B. java.util
C. java.net
D. java.network
Answer optionc
Marks: 1
Label lb=new Label("Advanced Java");Which method is used to obtain out
306 Java"
A. setText()
B. setLabel()
C. getText()
D. getLabel()
Answer optionc
Marks: 1
By using ___________ control, we can create a set of mutually exclusi
307 which one and only one checkbox in the group can be checked at a time.
A. Button
B. Checkbox
C. CheckboxGroup
D. List
Answer optionc
Marks: 1
Superclass of TextField and TextArea classes that is used to create si
308 Multiple textfields are
A. TextBox
B. TextComponent
C. Checkbox
D. Choice
Answer optionb
Marks: 1
309 Subclass of TextComponent is
A. TextArea
B. Button
C. Label
D. Checkbox
Answer optiona
Marks: 1
310 Following are constructors of TextArea class
A. TextArea(String str)
B. TextArea(int numLines,int numChars)
C. TextArea(String str,int numLines,int numChars,int sBars)
D. All of above
Answer optiond
Marks: 1
Which of these is a protocol for breaking and sending packets to an ad
311 network?
A. TCP/IP
B. DNS
C. Socket
D. Proxy Server
Answer optiona
Marks: 1
312 Which of the following is not an AWT class?
A. Label
B. CheckboxGroup
C. RadioButton
D. List
Answer optionc
Marks: 1
313 How many ports of TCP/IP are reserved for specific protocols?
A. 10
B. 1024
C. 2048
D. 512
Answer optionb
Marks: 1
314 Multiple selection of items in List is possible using following Constr
A. List()
B. List(int numRows)
C. List(int numRows,booean multipleSelect)
D. None of these
Answer optionc
Marks: 1
Which object can be constructed to show and select any number of choic
315 window?
A. Button
B. Choice
C. List
D. Label
Answer optionc
Marks: 1
316 Which method of Choice class is used to return index of the selected i
A. getSelectedIndex()
B. getSelectedIndexes()
C. getSelectedItem()
D. getSelectedItems()
Answer optiona
Marks: 1
317 Swing components that don't rely on Native GUI are reffered to as ____
A. GUI component
B. heavy weight component
C. Ligthweight component
D. middle weight component
Answer optionc
Marks: 1
How many bits are in a single IP address?
318
A. 8
B. 16
C. 32
D. 64
Answer optionc
Marks: 1
319 Developing GUI is swings does_________
A. uses buttons, menus, icons and all other components
B. should be easy for the end user to manipulate
C. stands for Graphic Use Interaction
D. Both (a) and (c)
Answer optiond
Marks: 1
320 Which of these functions is called to display the output of an applet?
A. display()
B. paint()
C. displayApplet()
D. PrintApplet()
Answer optionb
Marks: 1
321 _____AWT Component is used to select only one item from popup list of
A. Button
B. Choice
C. Checkbox
D. All of above
Answer optionb
Marks: 1
322 Choose the correct code to display the following output.
import javax.swing.*; import java.awt.*; import java.awt.event.*;
LabelExample extends Frame implements ActionListener{ JTextField tf
b; LabelExample(){ tf=new JTextField(); tf.setBounds(50,50, 150
JLabel(); l.setBounds(50,100, 250,20); b=new JButton("Find IP");
b.setBounds(50,150,95,30); b.addActionListener(this); add(b);a
A. setSize(400,400); setLayout(null); setVisible(true); } public
actionPerformed(ActionEvent e) { try{ String host=tf.getText(); St
ip=java.net.InetAddress.getByName(host).getHostAddress(); l.setText(
"+ip); }catch(Exception ex){System.out.println(ex);} } public st
main(String[] args) { new LabelExample(); } }
import javax.swing.*; import java.awt.*; import java.awt.event.*;
LabelExample extends Frame implements ActionListener{ JTextField tf;
b; LabelExample(){ tf=new JTextField(); tf.setBounds(50,50, 15
JButton("Find IP"); b.setBounds(50,150,95,30); b.addActionListener(
B. add(b);add(tf);add(l); setSize(400,400); setLayout(null); setV
public void actionPerformed(ActionEvent e) { try{ String host=tf.
ip=java.net.InetAddress.getByName(host).getHostAddress(); l.setText(
"+ip); }catch(Exception ex){System.out.println(ex);} } public
main(String[] args) { new LabelExample(); } }
import javax.swing.*; import java.awt.*; import java.awt.event.*;
LabelExample extends Frame implements ActionListener{ JTex
l; JButton b; LabelExample(){ tf=new JTe
C. JButton("Find IP"); b.setBounds(50,150,95,30);
b.addActionListener(this); add(b);add(tf);ad
main(String[] args) { new LabelExample();
implements ActionListener{ LabelExample(){ tf=new JTextField();
D. tf.setBounds(50,50, 150,20); l=new JLabel(); l.setBounds(50,100, 2
JButton("Find IP"); b.setBounds(50,150,95,30); b.addActionListene
add(b);add(tf);add(l); setSize(400,400); setLayout(null); setV
public void actionPerformed(ActionEvent e) { try{ String host=tf
String ip=java.net.InetAddress.getByName(host).getHostAddress(); l.se
"+host+" is: "+ip); }catch(Exception ex){System.out.println(ex);}
void main(String[] args) { new LabelExample(); } }
Answer optiona
Marks: 2
323 Which of these methods can be used to output a string in an applet?
A. display()
B. print()
C. drawString()
D. String()
Answer optionc
Marks: 1
324 Which component cannot be added to a container?
A. JPanel
B. JButton
C. JFrame
D. None of the above
Answer optionc
Marks: 1
Choose the correct syntax to create a table student with attributes ro
325 marks
A. CREATE TABLE STUDENT VALUES (ROLLNO 1, STUDNAME "ABC",MARKS 90);
B. CREATE TABLE STUDENT (ROLLNO INT, STUDNAME VARCHAR(10), MARKS INT);
C. CREATE TABLE STUDENT (ROLLNO NUMBER, STUDNAME STRING, MARKS INT);
D. All of the Above
Answer optionb
Marks: 1
Which statement is true with respect to the following code?
import java.awt.*;
import javax.swing.*;
public class Test { public static void main(String[] args) {
326 JFrame frame = new JFrame("My Frame"); frame.getContentPane().
JButton("OK")); frame.getContentPane().add(new JButton("Cancel"))
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSi
frame.setVisible(true); }}
A. Only button OK is displayed
B. Only button Cancel is displayed.
Both button OK and button Cancel are displayed and button OK is displa
C. side of button OK.
Both button OK and button Cancel are displayed and button OK is displa
D. side of button OK. FeedbackYour answer is correct.
Answer optionb
Marks: 2
What is the Message displayed in the applet made by this program?
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
{
327 public void paint(Graphics g)
{
g.drawString("A Simple Applet", 20, 20);
}
}
/*<applet code="myapplet.class" width=200 height=200></applet>*/
A. A Simple Applet
B. a simple applet
C. Compile error
D. None of the above
Answer optiona
Marks: 2
328 How many bits value does IPv4 and IPv6 uses to represent the address?
A. 32 and 64
B. 64 and 128
C. 32 and 128
D. . 64 and 64
Answer optionc
Marks: 1
What is the length of the application box made by this program?
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
329 {
Graphic g;
g.drawString("A Simple Applet", 20, 20);
}
A. 20
B. Default value
C. Compilation Error
D. Runtime Error
Answer optionc
Marks: 2
330 TCP,FTP,Telnet,SMTP,POP etc. are examples of ?
A. Socket
B. IP Address
C. Protocol
D. MAC Address
Answer optionc
Marks: 1
331 Which of following is subclass of java.awt.Component?
A. Container
B. LayoutManger
C. Color
D. Font
Answer optiona
Marks: 1
332 When should your program call repaint()?
A. Never--that is the system's job.
B. Only once when the frame is created.
C. Whenever it has made a change to what should be displayed in the F
D. Always---whenever any method finishes
Answer optionc
Marks: 1
Consider the following code:import java.awt.*;import javax.swing.*;pub
public static void main(String[] args) { Component c = new JButton("OK
333 new JFrame("My Frame"); frame.add(c);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible
You cannot add a Swing component directly to a JFrame. Instead, you ha
A. JFrame's contentPane using frame.getContentPane().add(c).
B. You cannot assign a JButton to a variable of java.awt.Component.
C. All of the above
D. None of the above
Answer optionb
Marks: 2
Which packages required for the program.
public class DeleteRecord
{
public static void main(String args[]) throws Exception
{
String sql;
Scanner sc=new Scanner(System.in);
System.out.println("Please Enter the ID no:");
int num = sc.readInt();
334 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:stud","scott
Statement stmt=con.createStatement();
int affectedRecords = stmt.executeQuery("select * from student whe
br.close();
stmt.close();
con.close();
}
}
A. import java.sql.*; import java.util.*;
B. import java.io.*; import java.util.*;
C. import java.sql.*; import java.io.*;
D. import java.sql.*; import java.stdio.*;
Answer optiona
Marks: 2
A Swing component can be viewed based on what state it's in, how it lo
335 does. This is known as the model-view- __________ model
A. Model
B. Controller
C. View
D. None of the above
Answer optionb
Marks: 1
Analyse the following code? import javax.swing.*; import java.awt.*;
public class Test extends JFrame { public Test() { setLayout(new
FlowLayout()); add(new JButton("Java")); add(new JButton("Java"));
add(new JButton("Java")); add(new JButton("Java")); } public static
336 void main(String [] args) { JFrame frame = new Test();
frame.setSize(200,100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true); } }
A. Four buttons are displayed with the same text java
B. One buttons are displayed with the same text java
C. Three buttons are displayed with the same text java
D. Five buttons are displayed with the same text java
Answer optiona
Marks: 2
Analyse the following code import javax.swing.*; Import
javax.swing.border.*; Import java.awt.*; Public class Test extends
JFrame { Public Test() { Border border=new TitledBorder("My button");
Jbutton jbt1=new JButton("OK"); Jbutton jbt=new JButton("Cancel");
Jbt1.setBorder(border); Jbt2.setBorder(border);
337 Add(jbt1,BorderLayout.NORTH); Add(jbt2,BorderLayout.NORTH); }
Public static void main(String[] args){ JFrame frame=new Test();
Frame.setSize(200,100);
Frame.setDefaultCloseOperation(JFrame.ExIT_ON_CLOSE);
Frame.setVisible(true); } }
A. The program has run time error
B. The program has compile error
C. No error
D. None of the above
Answer optionb
Marks: 2
To get the following output complete the code given below
import java.awt.*;
import javax.swing.*;
/*
<applet code="jscroll" width=300 height=250>
338 </applet>
*/
public class jscroll extends JApplet
{
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
}
}
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPanejsp = new JScrollPane(jp, v, h);
contentPane.add(jsp, BorderLayout.CENTER);
}
}
A. Container contentPane = getContentPane(); contentPane.setLayout(new Gr
B. JPanel jp = new JPanel(); jp.setLayout(new GridLayout(20, 20));
int b = 0; for(int i = 0; i < 20; i++) { for(int j = 0; j < 20; j++) {
C. JButton(
JPanel jp = new JPanel(); jp.setLayout(new GridLayout(3,3)); int b = 0
D. <3; i++) { for(int j = 0; j <3; j++) { jp.add(new JButton(
Answer optiond
Marks: 2
339 Following code shows given output
import java.awt.*; public class ChoiceExampleSimple extends Frame {
ChoiceExampleSimple(String s){ setL
A. c.add("C"); c.add("C++"); c.add("Java");
c.add("Android"); c.setBounds(100,100,100,100);
} }
import java.awt.*; public class ChoiceExampleSimple extends Frame {
ChoiceExampleSimple(String s){ setL
c.add("C"); c.add("C++"); c.add("Java");
B. c.add("Android"); c.setBounds(100,100,100,100); } pu
main(String args[]) { ChoiceExampleSimple f=new ChoiceExampleSi
} }
import java.awt.*; public class ChoiceExampleSimple extends Frame {
ChoiceExampleSimple(String s){ setL
c.add("Java"); c.add("PHP"); c.add("Android");
C. c.setBounds(100,100,100,100); add(c);
} public static void main(String args[]) { ChoiceExampleSimpl
ChoiceExampleSimple("Frame"); } }
D. All of above
Answer optiona
Marks: 2
For using Swing control one must
340 import______________________________package.
A. import javax.swing.*
B. import java.swing.*
C. Both A & B
D. None of the above
Answer optiona
Marks: 1
341 In Swing Buttons are the subclasses of which class?
A. AbstractButton
B. Button
C. Both A & B
D. None of the above
Answer optiona
Marks: 1
Applet class is a subclass of the panel class, which is again a subcla
342 the__________class
A. object
B. Component AW
C. awt
D. Container
Answer optiond
Marks: 1
Consider the program given below
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
/*
<applet code="test" width=300 height=100>
</applet>
*/
343 public class test extends JApplet
{
public void init()
{
Container co = getContentPane();
co.setLayout(new FlowLayout());
JComboBox jc=new JComboBox();
jc.addItem("cricket");
jc.addItem("football");
jc.addItem("hockey");
jc.addItem("tennis");
co.add(jc);
}
}
Choose the correct statement to get the following output
A. JComboBox jc=new JComboBox("Applet Viewer:test");
B. JComboBox jc=new JComboBox(cricket, football, hockey, tennis);
C. JComboBox jc=new JComboBox();
D. None of the above.
Answer optionc
Marks: 2
The____________method is called every time the applet receives focus a
344 scrolling in the active window.
A. init( )
B. start( )
C. stop( )
D. destroy( )
Answer optionb
Marks: 1
345 Which of the following applet tag is legal to embed an applet class na
webpage?
A.
B. <applet> code=Test.class width=200 height=100> </applet>
C. <applet code="Test.class" width=200 height=100> </applet>
D. <applet param=Test.class width=200 height=100> </applet>
Answer optionc
Marks: 1
Find the missing statement in the following code
import javax.swing.*;
class gui{
public static void main(String args[]){
JFrame frame = new JFrame("My First GUI");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
346 frame.setSize(300,300);
JButton button1 = new JButton("Press");
frame.getContentPane().add(button1);
----------------------------------
}
}
A. frame.setVisible(true);
B. frame.setVisible(False);
C. Both A & B
D. None of the above
Answer optiona
Marks: 2
347 The___________class is an abstract class that represents the display a
A. display()
B. graphics
C. text
D. area
Answer optionb
Marks: 1
Find the missing statement in the following code
import javax.swing.*;
/*
<applet code="JTabbedPaneDemo" width=400 height=100>
</applet>
*/
public class JTabbedPaneDemo extends JApplet
{
public void init()
{
JTabbedPane jtp = new JTabbedPane();
jtp.addTab("Languages", new LangPanel());
348 jtp.addTab("Colors", new ColorsPanel());
jtp.addTab("Flavors", new FlavorsPanel());
getContentPane().add(jtp);
}
}
class LangPanel extends JPanel
{
public LangPanel()
{
JButton b1 = new JButton("Marathi");
add(b1);
JButton b2 = new JButton("Hindi")
add(b2);
JButton b3 = new JButton("Bengali");
add(b3)
JButton b4 = new JButton("Tamil");add(b4);
}
}
class ColorsPanel extends JPanel
{
public ColorsPanel()
{
JCheckBox cb1 = new JCheckBox("Red");
add(cb1);
JCheckBox cb2 = new JCheckBox("Green");
add(cb2);
JCheckBox cb3 = new JCheckBox("Blue");
add(cb3);
}
}
class FlavorsPanel extends JPanel
{
public FlavorsPanel()
{
JComboBox jcb = new JComboBox();
jcb.addItem("Vanilla");
jcb.addItem("Chocolate");
jcb.addItem("Strawberry");
add(jcb);
}
}
A. Error
B. No Error
C. Both A & B
D. None of the above
Answer optiona
Marks: 2
Which of the following method of applet class is used to clear the sc
349 paint( ) method
A. update( )
B. paint( )
C. repaint( )
D. reupdate( )
Answer optiona
Marks: 1
Observe the following code and Choose the correct output from the give
import java.awt.*;
import javax.swing.*;
public class test extends JFrame
{
public test()
{
super("Login Form");
Container cpane=getContentPane();
cpane.setLayout(new FlowLayout());
JLabel l1=new JLabel("Name");
JLabel l2=new JLabel("Password");
JTextField t1=new JTextField(20);
350 JTextField t2=new JTextField(20);
JButton b1=new JButton("Login");
JButton b2=new JButton("Cancel");
cpane.add(l1);
cpane.add(t1);
cpane.add(l2);
cpane.add(t2);
cpane.add(b1);
cpane.add(b2);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String args[])
{
test obj=new test();
obj.setVisible(true);
obj.setSize(200,200);
}
}
A.
B.
C. None of the above
D.
Answer optiond
Marks: 2
The__________method is automatically called the first time the applet
351 screen and every time the applet receives focus.
A. update( )
B. paint( )
C. repaint( )
D. reupdate( )
Answer optionb
Marks: 1
Find the missing statement in the following code
352 import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ButtonDemo extends JFrame
{
JButton yes,no,close;
JLabel lbl;
ButtonDemo()
{
yes = new JButton("YES");
no = new JButton ("No");
close = new JButton ("CLOSE");
lbl = new JLabel ("");
__________________________
setSize (400,200);
add(yes);
add(no);
add(close);
add(lbl);
setVisible(true);
//setDefaultCloseOperation(JFrame.EXIT_NO_CLOSE);
ButtonHandler bh = new ButtonHandler();
yes.addActionListener(bh);
yes.addActionListener(bh);
no.addActionListener(bh);
close.addActionListener(bh);
}
class ButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
if (ae.getSource()==yes)
{
lbl.setText("Button Yes is pressed");
}
if (ae.getSource()==no)
{
lbl.setText("Button No is pressed");
}
if (ae.getSource()==close)
{
System.exit(0);
}
}
}
public static void main(String args[])
{
n
A. setLayout (new GridLayout(4,1));
B. setLayout (new borderLayout(4,1));
C. setLayout (new flowLayout(4,1));
D. None of the above
Answer optiona
Marks: 2
The___________method is defined by the AWT which causes the AWT runtim
353 a call to your applet’s update( ) method.
A. update( )
B. paint( )
C. repaint( )
D. reupdate()
Answer optionc
Marks: 1
354 which code gives following output ?
import java.awt.*; import java.applet.*; /* <applet code="Buttonexampl
height=200> </applet> */ public class Buttonexample extends Applet {
A. init() { Button b1=new Button("ok"); Butt
Button("cancel"); Button b3=new Button("exit");
add(b1);add(b2);add(b3); } }
import java.awt.*; import java.applet.*; /* <applet code="Buttonexampl
height=200> </applet> */ public class Buttonexample extends Applet {
B. init() { Button b1=new Button("ok"); Butt
Button("cancel"); Button b3=new Button("exit");
add(b2);add(b1);add(b3); } }
import java.awt.*; import java.applet.*; /* <applet code="Buttonexampl
height=200> </applet> */ public class Buttonexample extends Applet {
C. init() { Button b1=new Button("ok"); Butt
Button("cancel"); Button b3=new Button("exit");
add(b3);add(b1);add(b2); } }
import java.awt.*; import java.applet.*; /* <applet code="Buttonexampl
height=200> </applet> */ public class Buttonexample extends Applet {
D. init() { Button b1=new Button("ok"); Butt
Button("cancel"); Button b3=new Button("exit");
add(b3);add(b2);add(b1); } }
Answer optionb
Marks: 2
What is the output of the following code ?
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
class solution extends JFrame {
static JFrame f;
static JButton b, b1, b2, b3;
355 static JLabel l;
public static void main(String[] args)
{
f = new JFrame("panel");
l = new JLabel("panel label");
b = new JButton("button1"); b1 = new JButton("button2");
b2 = new JButton("button3"); b3 = new JButton("button4");
JPanel p = new JPanel(new BorderLayout());
p.add(b, BorderLayout.NORTH); p.add(b1, BorderLayout.SOUTH);
p.add(b2, BorderLayout.EAST); p.add(b3, BorderLayout.WEST)
p.add(l, BorderLayout.CENTER);
p.setBackground(Color.red);
f.add(p);
f.setSize(300, 300); f.show(); } }
A.
B.
C.
D.
Answer optiona
Marks: 2
356 In Swing ____________is a component that displays rows and columns of
A. Tabpane
B. Table
C. Scrollpane
D. None of the above
Answer optionb
Marks: 1
357 Which of the following method is used to display numerical values in a
A. paint( )
B. drawstring( )
C. draw( )
D. convert( )
Answer optionb
Marks: 1
Consider the following program What will be the output?
import java.sql.*; class Example
{ public static void main(String srgs[])
{ try
358 { Class.forname("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:STUD");
System.out.println("connection Established");
} catch(sQLException e) { System.out.pritln("SQL error"); } catch(Exc
System.out.println("error"); }}}
A. error ; missing
B. Error } missing
C. Connection Established
D. SQL error
Answer optionc
Marks: 2
We can change the text to be displayed by an applet by supplying new t
359 a____________tag.
A.
B.
C.
D.
Answer optiond
Marks: 1
Which of the following is/are the possible values for alignment attrib
360 i) Top ii) Left iii) Middle iv) Baseline
A. i, ii and iii only
B. ii, iii and iv only
C. i, iii and iv only
D. All i, ii, iii and iv
Answer optiond
Marks: 1
We can change the text to be displayed by an applet by supplying new t
361 through________tag.
A. SPACE=pixels
B. HSPACE=pixels
C. HWIDTH=pixels
D. HBLANK=pixels
Answer optionb
Marks: 1
Debug the following program
import java.awt.*;
import javax.swing.*;
/*
<applet code="JTableDemo" width=400 height=200>
</applet>
*/
public class JTableDemo extends JApplet
{
public void init() {
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
362 final String[] colHeads = { "emp_Name", "emp_id", "emp_salary" };
final Object[][] data = {
{ "Ramesh", "111", "50000" },
{ "Sagar", "222", "52000" },
{ "Virag", "333", "40000" },
{ "Amit", "444", "62000" },
{ "Anil", "555", "60000" },
};
JTable table = new JTable(data,colHeads);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(table, v, h);
contentPane.add(jsp, BorderLayout.CENTER);}}
A. Error in statement in which JTable is created
B. Error in statement in which JScrollPane is created
C. Error in statement in which Horizontal Scrollbar is declared
D. None of the above
Answer optionc
Marks: 2
__________attribute of applet tag specify the width of the space on th
363 will reserved for the applet.
A. WIDTH=pixels
B. HSPACE=pixels
C. HWIDTH=pixels
D. HBLANK=pixels
Answer optiona
Marks: 1
Consider following code and state missing code?
import java.sql.*;
class Demo1{
public static void main(String args[])throws Exception
{
try
{
Class.forName("_________________________________________");
364 Connection con=DriverManager.getConnection("Jdbc:Odbc:demo");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from student");
while(rs.next())
{
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" " +rs.getString(
}
catch(Exception e) {} } }
A. sun.odbc.jdbc.OdbcJdbcDriver
B. oracle.jdbc.driver.OracleDriver
C. sun.jdbc.odbc.JdbcOdbcDriver
D. None of the Above
Answer optionc
Marks: 2
365 What is the super class of container?
A. java.awt.Container
B. java.awt.Component
C. java.awt.Panel
D. java.awt.Layout
Answer optionb
Marks: 1
Following methods belongs to which class?
1) public void add(Component c)
366 2) public void setSize(int width,int height)
3) public void setLayout(LayoutManager m)
4) public void setVisible(boolean)
A. Graphics class
B. Component class
C. Both A & B
D. None of the above
Answer optionb
Marks: 1
367 __________is a server that is mediator between real web server and cli
A. IBMServer
B. SQLServer
C. ReserverSockets
D. Proxy server
Answer optiond
Marks: 1
368 Port number 80 is reserved for
A. FTP
B. Telnet
C. e-mail
D. HTTP
Answer optiond
Marks: 1
369 View Data helps you to maintain data when you move from --------------
A. Controller to View
B. Temp Data
C. Controller to Data
D. None of above
Answer optiona
Marks: 1
370 What is the purpose of JTable?
A. JTable object displays ONLY rows
B. JTable object displays ONLY columns
C. JTable object displays both rows and columns
D. JTable object displays data in Tree form
Answer optionc
Marks: 1
371 MVC is composed of three components:
A. Member Vertical Controller
B. Model View Control
C. Model View Controller
D. Model Variable Centered
Answer optionc
Marks: 1
372 __________method is used to know the type of content used in the URL.
A. ContentType()
B. Contenttype()
C. GetContentType()
D. getContentType()
Answer optiond
Marks: 1
373 Which of the following is TRUE?
A. Action method can be static method in a controller class
B. Action method can be private method in a controller class
C. Action method can be protected method in a controller class
D. Action method must be public method in a controller class
Answer optiond
Marks: 2
374 Port number 25 is reserved for
A. FTP
B. Telnet
C. SMTP
D. HTTP
Answer optionc
Marks: 1
375 To hold component ___________ are used
A. Container
B. AWT
C. Both
D. None
Answer optiona
Marks: 1
376 What parameter we can pass to public int getInt() method?
A. int columnIndex
B. int row
C. Both
D. None of the above
Answer optiona
Marks: 1
Find the error in the following code :
import java.awt.*;
import javax.swing.*;
/*<applet code="test" width=200 height=200>
</applet>*/
public class test extends JApplet
{
public void init()
{
Container c=getContentPane();
JTabbedPane jp=new JTabbedPane();
JButton b1=new JButton("COMP.TECH");
p1.add(b1);
JButton b2=new JButton("INFO.TECH");
377 p1.add(b2);
JButton b3=new JButton("ELEC.ENGG");
p1.add(b3);
JButton b4=new JButton("FIRST");
p2.add(b4);
JButton b5=new JButton("SECOND");
p2.add(b5);
JButton b6=new JButton("THIRD");
p2.add(b6);
jp.addTab("Branch",p1);
jp.addTab("Year",p2);
c.add(jp);
}
}
A. JPanel p2=new JPanel(); JButton b3=new JButton();
B. variable p1 ,cannot find symbol
C. /*<applet code="test" width=200 height=200> </applet>*/
D. jp.addTab()
Answer optionb
Marks: 2
378 List out few different return types of a controller action method
A. View Result
B. Javascript Result
C. Redirect Result
D. All of these
Answer optiond
Marks: 1
379 What are the steps for the execution of an MVC project?
A. Receive first request for the application
B. Performs routing
C. Creates MVC request handler
D. All of the above
Answer optiond
Marks: 1
Which method of a Frame object is used to place a GUI component (such
380 the Frame?
A. . insert( Component c )
B. add( Component c )
C. draw( Component c )
D. click( Component c )
Answer optionb
Marks: 1
381 Which of following is TRUE?
A. The controller redirects incoming request to model
B. The controller executes an incoming request
C. The controller controls the data
D. The controller render html to view
Answer optionb
Marks: 1
382 Which class is used to encapsulate IP address and DNS?
A. URLConnection
B. Telnet
C. DatagramPacket
D. netAddress
Answer optiond
Marks: 1
A JFrame supports three operations when the user closes the window. Wh
383 below is not one of the three:
A. LOWER_ON_CLOSE
B. DISPOSE_ON_CLOSE.
C. DO_NOTHING_ON_CLOSE
D. HIDE_ON_CLOSE.
Answer optiona
Marks: 1
384 What is the return type of getString() method?
A. String
B. int
C. byte
D. short
Answer optiona
Marks: 1
385 Which is the correct code for displaying following output
import javax.swing.*; public class TableExample {
TableExample(){ f=new JFrame(); String data[][
{"101","Amit","670000"}, {"102","Jai
{"101","Sachin","700000"}}; String column[]={"ID","NAME","
A. JTable jt=new JTable(data,column); jt.setBounds(30,40,200,
JScrollPane sp=new JScrollPane(jt); f.add(sp);
f.setSize(300,400); f.setVisible(true); } publi
main(String[] args) { } }
import javax.swing.*; public class TableExample {
TableExample(){ f=new JFrame(); String data[][
{"101","Amit","670000"}, {"102","Jai
{"101","Sachin","700000"}}; String column[]={"ID","NAME","
B. JTable jt=new JTable(data,column); jt.setBounds(30,40,200,
JScrollPane sp=new JScrollPane(jt); f.add(sp);
public static void main(String[] args) { new TableExample(
}
import javax.swing.*; public class TableExample {
TableExample(){ f=new JFrame(); String data[][
{"101","Amit","670000"}, {"102","Jai
C. {"101","Sachin","700000"}}; String column[]={"ID","NAME","
JTable jt=new JTable(data,column); jt.setBounds(30,40,200,
f.setSize(300,400); f.setVisible(true); } publi
main(String[] args) { new TableExample(); }
import javax.swing.*; public class TableExample {
TableExample(){ f=new JFrame(); String data[][
D. {"101","Amit","670000"}, {"102","Jai
{"101","Sachin","700000"}}; String column[]={"ID","NAME","
JTable jt=new JTable(data,column); jt.setBounds(30,40,200,
JScrollPane sp=new JScrollPane(jt); f.add(sp);
f.setSize(300,400); f.setVisible(true); } publi
main(String[] args) { new TableExample(); }
Answer optiond
Marks: 2
Select correct output for following code:
import javax.swing.*;
import java.awt.event.*;
class RadioButtonExample extends JFrame implements ActionListener{
JRadioButton rb1,rb2; JButton b;
RadioButtonExample(){
rb1=new JRadioButton("Male");
rb1.setBounds(100,50,100,30);
rb2=new JRadioButton("Female");
rb2.setBounds(100,100,100,30);
ButtonGroup bg=new ButtonGroup();
bg.add(rb1);bg.add(rb2);
b=new JButton("click");
386 b.setBounds(100,150,80,30);
b.addActionListener(this);
add(rb1);add(rb2);add(b);
setSize(300,300);
setLayout(null); setVisible(true); }
public void actionPerformed(ActionEvent e){
if(rb1.isSelected()){
JOptionPane.showMessageDialog(this,"You are Male.");
}
if(rb2.isSelected()){
JOptionPane.showMessageDialog(this,"You are Female.");
} }
public static void main(String args[]){
new RadioButtonExample(); }}
A.
B.
C.
D.
Answer optiona
Marks: 2
387 Port number 21 is reserved for
A. FTP
B. Telnet
C. e-mail
D. HTTP
Answer optiona
Marks: 1
388 Select the code for following output:
import javax.swing.*; public class TabbedPaneExample { TabbedPane
f=new JFrame(); JTextArea ta=new JTextArea(200,200); JPane
p1.add(ta); JPanel p2=new JPanel(); JPanel p3=new JPanel()
A. tp=new JTabbedPane(); tp.setBounds(50,50,200,200); tp.add(
tp.add("visit",p2); tp.add("help",p3); f.add(tp);
f.setLayout(null); f.setVisible(true); } public static void
{ new TabbedPaneExample(); }}
import javax.swing.*; public class TabbedPaneExample { JFrame f;
TabbedPaneExample(){ f=new JFrame(); JTextArea ta=new JTex
JPanel p1=new JPanel(); p1.add(ta); JPanel p2=new JPanel()
B. p3=new JPanel(); JTabbedPane tp=new JTabbedPane();
tp.setBounds(50,50,200,200); tp.add("main",p1); tp.add("vi
tp.add("help",p3); f.add(tp); f.setSize(400,400);
f.setVisible(true); } public static void main(String[] args) {
TabbedPaneExample(); }}
import javax.swing.*; public class TabbedPaneExample { JFrame f;
TabbedPaneExample(){ f=new JFrame(); JTextArea ta=new JTex
p1.add(ta); JPanel p2=new JPanel(); JPanel p3=new JPanel()
C. tp=new JTabbedPane(); tp.setBounds(50,50,200,200); tp.add(
tp.add("visit",p2); tp.add("help",p3); f.add(tp);
f.setLayout(null); f.setVisible(true); } public static void
{ new TabbedPaneExample(); }}
import javax.swing.*; public class TabbedPaneExample { JFrame f;
TabbedPaneExample(){ f=new JFrame(); JTextArea ta=new JTex
JPanel p1=new JPanel(); p1.add(ta); JPanel p2=new JPanel()
D. p3=new JPanel(); JTabbedPane tp=new JTabbedPane();
tp.setBounds(50,50,200,200); f.add(tp); f.setSize(4
f.setLayout(null); f.setVisible(true); } public static void
{ new TabbedPaneExample(); }}
Answer optionb
Marks: 2
Which of the following statements are true.
1. ResultSet object can be moved forward only and it is not updatable.
2. The object of ResultSet maintains a cursor pointing to a row of a t
389 3. The statement interface is a factory of ResultSet
4. The performance of the application will be faster if you use Prepar
interface
A. 1,2,3
B. 2,4
C. 1,3,4
D. 1,2,3,4
Answer optiond
Marks: 1
390 The Transmission Control Protocol
A. Support fast transfer of packets
B. support connectionless transport of packets
C. support unreliable transport of packets
D. support connection oriented transport of packets
Answer optiond
Marks: 1
391 Which of the following methods cannot be called on JLabel?
A. setIcon()
B. getText()
C. setLabel()
D. setBorderLayout()
Answer optiond
Marks: 1
392 User Datagram Protocol is__________
A. Support fast transfer of packets
B. support connection-less transport of packets
C. support unreliable transport of packets
D. All of the above
Answer optiond
Marks: 1
393 A JTabbedPane does the following operations_____________________
A. arranges GUI components into layers such that only one layer is visibl
B. allows users to access a layer of GUI components via a tab
C. extends JComponent
D. All of the above.
Answer optiond
Marks: 1
394 Where are the tabs on a JTabbedPane placed by default
A. top
B. bottom
C. left
D. right.
Answer optiona
Marks: 1
Find the missing statement from the below given code :-
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class menu extends JFrame {
// menubar
static JMenuBar mb;
// JMenu
static JMenu x;
// Menu items
static JMenuItem m1, m2, m3;
// create a frame
static JFrame f;
public static void main()
{
395
// create a frame
f = new JFrame("Menu demo");
// create a menubar
mb = new JMenuBar();
// create a menu
x = new JMenu("Menu");
// create menuitems
m1 = new JMenuItem("MenuItem1");
m2 = new JMenuItem("MenuItem2");
m3 = new JMenuItem("MenuItem3");
// add menu items to menu
x.add(m1);
x.add(m2);
x.add(m3);
// add menu to menu bar
___________________
// add menubar to frame
f.setJMenuBar(mb);
// set the size of the frame
f.setSize(500, 500);
f.setVisible(true);
}
}
A. m1 = new JMenuItem("MenuItem1");
B. x.add(m1);
C. f.setVisible(true);
D. mb.add(x);
Answer optiond
Marks: 1
396 The Transmission Control Protocol is
A. Low level routing protocol
B. Middle level routing protocol
C. Higher level routing protocol
D. None of above
Answer optionc
Marks: 1
397 Mnemonics can be used with all sub classes of which class?
A. JComponent
B. JMenu
C. JMenuItem
D. All of the above
Answer optiond
Marks: 1
398 Menus are attached to the windows by calling___________ method
A. addMenus()
B. setMenu()
C. setJMenuBar()
D. addJMenuBar()
Answer optionc
Marks: 1
The elements of a _________ Layout are organized in a top to bottom, l
399 pattern.
A. Grid
B. Border
C. Card
D. Flow
Answer optiond
Marks: 1
From the following program select the output.
import java.awt.*;
import javax.swing.*;
public class JTPDemo extends JApplet
{
public void init()
{
JTabbedPane jt = new JTabbedPane();
jt.add("Colors", new CPanel());
jt.add( "Fruits", new FPanel());
jt.add("Vitamins", new VPanel( ) ) ;
getContentPane().add(jt);
}
}
class CPanel extends JPanel
400 {
public CPanel()
{
JCheckBox cb1 = new JCheckBox("Red");
JCheckBox cb2 = new JCheckBox("Green");
JCheckBox cb3 = new JCheckBox("Blue");
add(cb1); add(cb2); add(cb3) ;
}
}
class FPanel extends JPanel
{
public FPanel()
{
JComboBox cb = new JComboBox();
cb.addItem("Apple");
cb.addItem("Mango");
cb.addItem("Pineapple");
add(cb);
}
}
class VPanel extends JPanel
{
public VPanel()
{
JButton b1 = new JButton("Vit-A");
JButton b2 = new JButton("Vit-B");
JButton b3 = new JButton("Vit-C");
add(b1); add(b2); add(b3);
}
}
A.
B.
C. Both A & B
D. None of the above
Answer optionb
Marks: 2
401 Internet Protocol is
A. Low level routing protocol
B. Middle level routing protocol
C. Higher level routing protocol
D. None of above
Answer optiona
Marks: 1
402 Cookies were originally designed for
A. Client-side programming
B. Server-side programming
C. Both Client-side & Server-side programming
D. web programming
Answer optionb
Marks: 1
403 What happens if setSize() is not called on a JFrame ?
A. The window is displayed at its preferred size
B. The window is not displayed
C. The window is displayed at its absolute size
D. Only the title bar appears
Answer optionb
Marks: 1
When the user press Enter key in a JTextField, the GUI component gener
404 an_____________ , _______________ which is processed by an object th
interface.
A. ActionEvent, ActionListener
B. ActionEvent, TextEventListener.
C. TextEvent, TextListener
D. TextEvent, ActionEventListener
Answer optiona
Marks: 2
The following specifies the advantages of ____
405 It is lightweight.
It supports pluggable look and feel.
It follows MVC (Model View Controller) architecture.
A. AWT
B. SWING
C. Both A & B
D. None of the above
Answer optionb
Marks: 1
406 What is in terms of JDBC ,a DataSource
A. A DataSource is the basic service for managing a set of JDBC drivers
B. DataSource is a java representation of physical data source
C. DataSource is a registry point
D. DataSource is a factory of connections to a physical data source
Answer optiond
Marks: 2
Which of the following encapsulates an SQL statement which is passed t
407 be parsed, compiled, planned and executed?
A. DriverManager
B. Connection
C. JDBC Driver
D. Statement
Answer optiond
Marks: 2
408 Which driver is efficient and preferable for using JDBC applications?
A. Type 1
B. Type 2
C. Type 3
D. Type 4
Answer optiond
Marks: 1
409 Which packages contains JDBC classes?
A. java.jdbc
B. java.jdbc.sql
C. java.sql
D. java.rdb
Answer optionc
Marks: 1
410 Which of the following methods are needed for loading the database dri
A. resultSet method
B. class.forName() method
C. getConnection()
D. Both A and B
Answer optionb
Marks: 2
411 Is the JDBC-ODBC bridge multithreaded ?
A. True
B. False
C. can't predict
D. don't know
Answer optiona
Marks: 1
412 ________ is an open source DBMS product that runs on UNIX, Linux and W
A. MySQL
B. JSP/SQL
C. JDBC/SQL
D. Sun ACCESS
Answer optiona
Marks: 2
413 Which driver is efficient and always preferable for using JDBC applica
A. Type 1 driver
B. Type 2 driver
C. Type 3 driver
D. Type 4 driver
Answer optiond
Marks: 1
414 Which model does a Java applet or application talks directly to the da
A. Two Tier Model
B. Three Tier Model
C. Both A and B
D. None of the above
Answer optiona
Marks: 1
415 What is the reason that a java program cannot directly communicate wit
A. ODBC written in C# language
B. ODBC written in C language
C. ODBC written in C++ language
D. None of the above
Answer optionb
Marks: 2
416 Which models do the JDBC API support for the database access?
A. Two Tier Model
B. Three Tier Model
C. Both A and B
D. None of the above
Answer optionc
Marks: 2
417 ODBC stands for?
A. Open database connectivity
B. Open database concept
C. Open database communications
D. None of the above
Answer optiona
Marks: 1
418 Which class has traditionally been the backbone of the JDBC architectu
A. the JDBC driver manager
B. the JDBC driver test suite
C. the JDBC-ODBC bridge
D. All mentioned above
Answer optiona
Marks: 2
Which method is used to establish the connection with the specified ur
419 Manager class?
A. public static void registerDriver(Driver driver)
B. public static void deregisterDriver(Driver driver)
C. public static Connection getConnection(String url)
D. None of the above
Answer optionc
Marks: 2
Consider the following program.What should be the correction done in t
correct output?
import java.sql.*;
class Ddemo1
{{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
420 Statement s=c.createStatement();
ResultSet rs=s.executeQuery("select *from StudTable");
System .out.println("Name" + " " + "Roll_No" + " " + "Avg");while
System.out.println(rs.getString(1)+" "+rs.getInt(2)+" "+rs
}
s.close();
c.close();
}}
A. Missing semicolon
B. Missing {
C. Missing }
D. Missing statement.
Answer optiond
Marks: 2
Consider the following program Select the statement that should be add
to get correct output.
import java.sql.*;
public class db
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:XYZ","","");
PreparedStatement s=c.prepareStatement( "update db3 set Name=? where R
Statement s=c.createStatement( );
421 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"+" "+"Roll no"+" "+"Avg");
while(rs.next())
{
System.out.println(rs.getString(1)+" "+rs.getInt(2)+" "+rs.getDo
}
s.close();
c.close();
}}
A. s.executeUpdate()
B. c.createStatement( )
C. s.close()
D. c.close()
Answer optiona
Marks: 2
Consider the following program. What should be the correction done in
correct output?
class Ddemo1
{public static void main(String args[]) throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
Statement s=c.createStatement();
422 ResultSet rs=s.executeQuery("select *from StudTable");
System .out.println("Name" + " " + "Roll_No" + " " + "Avg");
while(rs.next())
{
System.out.println(rs.getString(1)+" "+rs.getInt(2)+" "+rs
}
s.close();
c.close();
}}
A. Missing semicolon
B. Missing {
C. Missing }
D. Missing package statement.
Answer optiond
Marks: 2
423 Which of the following is correct about driver interface of JDBC?
A. JDBC driver is an interface enabling a Java application to interact wi
B. JDBC API is an application interface of javafor connecting java as bac
C. Both A and B
D. None of the above
Answer optiona
Marks: 2
424 Which of the following is correct about Statement?
A. Used for general-purpose access to your database.
B. Useful when you are using static SQL statements at runtime.
C. Both of the above.
D. None of the above.
Answer optionc
Marks: 2
Connection object can be initialized using the____________method of th
425 class.
A. putConnection()
B. setConnection()
C. Connection()
D. getConnetion()
Answer optiond
Marks: 1
426 The _________________ method executes an SQL statement that may return
A. .executeUpdate()
B. executeQuery()
C. execute()
D. noexecute()
Answer optionc
Marks: 2
427 ________Use to execute parameterized query?
A. Statement Interface
B. PreparedStatement interface
C. ResultSet Interface
D. None of the above
Answer optionb
Marks: 2
428 Every driver must provide a class that should implement the___________
A. Driver interface
B. Driver manager
C. Driver class
D. Driver
Answer optiona
Marks: 2
429 How can you execute a stored procedure in the database?
A. Call method execute() on a CallableStatement object
B. Call method executeProcedure() on a Statement object
C. Call method execute() on a StoredProcedure object
D. Call method run() on a ProcedureCommand object
Answer optiona
Marks: 1
430 Which of the following is false as far as type 4 driver is concern?
A. Type 4 driver is native protocol, pure java driver
B. Type 4 drivers are 100% Java compatible
C. Type 4 drivers uses Socket class to connect to the database
D. Type 4 drivers can not be used with Netscape
Answer optiond
Marks: 1
431 Which driver is efficient and always preferable for using JDBC applica
A. Type 4
B. Type 3
C. Type 2
D. Type 1
Answer optiona
Marks: 1
432 The JDBC-ODBC bridge is
A. Three tiered
B. Multithreaded
C. Best for any platform
D. All of the above
Answer optionb
Marks: 1
433 Which driver is called as thin-driver in JDBC?
A. Type-4 driver
B. Type-1 driver
C. Type-2 driver
D. Type-3 driver
Answer optiona
Marks: 1
434 _____interface allows storing results of query?
A. Statement
B. Connection
C. ResultSet
D. None of the above
Answer optionc
Marks: 2
Which layout manager should you use to arrange the components of conta
435 form?
A. Grid Layout
B. Card Layout
C. Border Layout
D. Flow Layout
Answer optiona
Marks: 1
436 Which of the following is the default layout for a applet?
A. Grid Layout
B. Card Layout
C. Border Layout
D. Flow Layout
Answer optiond
Marks: 1
437 Which of the following is the default layout for Frame?
A. Grid Layout
B. Card Layout
C. Border Layout
D. Flow Layout
Answer optionc
Marks: 1
438 Which of the following statement is correct to change the layout of
A. setLayoutManager(new GridLayout());
B. setLayout(new GridLayout(2,2));
C. setGridLayout(2,2);
D. setBorderLayout();
Answer optionb
Marks: 1
439 Which method is used to set the layout of a container?
A. startLayout()
B. initLayout()
C. layoutContainer()
D. setLayout()
Answer optiond
Marks: 1
440 Which containers use a Borderlayout as their default layout?
A. Window
B. Frame
C. Dialog
D. All of the above
Answer optiond
Marks: 1
--------------arranges the components as a deck of cards such that onl
441 visible at a time.
A. Grid Layout
B. Card Layout
C. Border Layout
D. Flow Layout
Answer optionb
Marks: 1
442 Select the correct option to get the given output.
import java.awt.*; import javax.swing.*; public class Border {
Border(){ f=new JFrame(); JButton b1=new JButton("N
JButton b2=new JButton("SOUTH");; JButton b3=new JButton("EAST")
A. b4=new JButton("WEST");; JButton b5=new JButton("CENTER");;
f.add(b1,BorderLayout.NORTH); f.add(b2,BorderLayout.SOUTH);
f.add(b3,BorderLayout.EAST); f.add(b4,BorderLayout.WEST);
f.add(b5,BorderLayout.CENTER); f.setSize(300,300);
} public static void main(String[] args) { new Border(); }
import java.awt.*; import javax.swing.*; public class Border {
Border(){ f=new JFrame(); JButton b1=new JButton("N
JButton b2=new JButton("SOUTH");; JButton b3=new JButton("EAST")
b4=new JButton("WEST");; JButton b5=new JButton("CENTER");;
B. f.add(b1,BorderLayout.NORTH); f.add(b2,BorderLayout.RIGHT);
f.add(b3,BorderLayout.EAST); f.add(b4,BorderLayout.LEFT);
f.add(b5,BorderLayout.CENTER); f.setSize(300,300);
} public static void main(String[] args) { new Border(); }
import java.awt.*; import javax.swing.*; public class Border {
Border(){ f=new JFrame(); JButton b1=new JButton("N
JButton b2=new JButton("SOUTH");; JButton b3=new JButton("EAST")
b4=new JButton("WEST");; JButton b5=new JButton("CENTER");;
C. f.add(b1,BorderLayout.TOP); f.add(b2,BorderLayout.RIGHT);
f.add(b3,BorderLayout.BOTTOM); f.add(b4,BorderLayout.LEFT);
f.add(b5,BorderLayout.CENTER); f.setSize(300,300);
} public static void main(String[] args) { new Border(); }
import java.awt.*; import javax.swing.*; public class Border {
Border(){ f=new JFrame(); JButton b1=new JButton("N
JButton b2=new JButton("SOUTH");; JButton b3=new JButton("EAST")
b4=new JButton("WEST");; JButton b5=new JButton("CENTER");;
D. f.add(b1,BorderLayout.TOP); f.add(b2,BorderLayout.SOUTH);
f.add(b3,BorderLayout.BOTTOM); f.add(b4,BorderLayout.WEST);
f.add(b5,BorderLayout.CENTER); f.setSize(300,300);
} public static void main(String[] args) { new Border(); }
Answer optiona
Marks: 2
import java.awt.*;
import javax.swing.*;
public class MyFlowLayout{
JFrame f;
443 MyFlowLayout(){
f=new JFrame();
JButton b1=new JButton("1");
JButton b2=new JButton("2");
JButton b3=new JButton("3");
JButton b4=new JButton("4");
JButton b5=new JButton("5");
f.add(b1);f.add(b2);f.add(b3);f.add(b4);f.add(b5);
-----------------------------------------
//setting flow layout of right alignment
f.setSize(300,300);
f.setVisible(true);
}
public static void main(String[] args) {
new MyFlowLayout();
}
}
Find the missing statement to get the following output
A. f.setLayout(new FlowLayout());
B. f.setLayout(new FlowLayout(FlowLayout.RIGHT));
C. f.setLayout(new FlowLayout(FlowLayout.CENTRE));
D. f.setLayout(new FlowLayout(FlowLayout.LEFT));
Answer optionb
Marks: 2
Which of the following layout manager should be used so that every com
444 same size in the container?
A. Grid Layout
B. Card Layout
C. Border Layout
D. Flow Layout
Answer optiona
Marks: 1
import java.awt.*;
class SampleFrame extends Frame
{
SampleFrame(String title)
{
super(title);
}
}
class FileDialogDemo
{
445 public static void main(String args[])
{
Frame f = new SampleFrame("File Dialog Demo");
----------------------------
f.setSize(100, 100);
FileDialog fd = new FileDialog(f, "File Dialog");
fd.setVisible(true);
}
}
Find the missing statement to get the given output.
A. fd.setVisible(true);
B. f.setVisible(false);
C. fd.setVisible(false);
D. f.setVisible(true);
Answer optiond
Marks: 2
446 In CardLayout where components of every card are added?
A. Window
B. Panel
C. Applet
D. Frame
Answer optionb
Marks: 1
447 Select correct statement to add component in south region-----
A. add(component obj,FlowLayout.SOUTH);
B. add(component obj,BorderLayout.RIGHT);
C. add(component obj,BorderLayout.SOUTH);
D. add(component obj,FlowLayout.RIGHT);
Answer optionc
Marks: 1
448 Which of the following statements are used to create panel in border l
A. Frame p=new Frame(new BorderLayout());
B. Panel p=new Panel(); p.setLayout(new BorderLayout());
C. Panel p=new Panel();
D. Panel p=new Panel(); p.setLayout(new Border());
Answer optionb
Marks: 2
449 ---------------is used to position components in an applet window.
A. Layout Manager
B. addComponent();
C. add()
D. Both a and b
Answer optiona
Marks: 1
450 What is use of GridLayout Manager ?
A. To lay out components in a two-dimensional grid
B. To lay components in tabular form
C. Both a and b
D. none of the above
Answer optionc
Marks: 1
451 Which of the following is used to rollback a JDBC transaction?
A. rollback()
B. rollforward()
C. deleteTransaction()
D. RemoveTransaction()
Answer optiona
Marks: 2
452 When the message "No Suitable Driver" occurs?
A. When the driver is not registered by Class.forname() method
B. When the user name, password and the database does not match
C. When the JDBC database URL passed is not constructed properly
D. When the type 4 driver is used
Answer optionc
Marks: 2
453 What is the disadvantage of Type-4 Native-Protocol Driver?
A. At client side, a separate driver is needed for each database
B. Type-4 driver is entirely written in Java
C. The driver converts JDBC calls into vendor-specific database protocol
D. It does not support to read MySQL data
Answer optiona
Marks: 2
454 The Java software Bridge provides JDBC access via__________
A. ODBC drivers
B. JDBC API
C. Both A and B
D. None of the above
Answer optiona
Marks: 1
455 Which statement about JDBC are true
A. JDBC is an API to connect relational-object and XML data sourses
B. JDBC stands for Java Database Connectiivity
C. JDBC is an API to access relational database.
JDBC is an API to bridge the object-relational mismatch between OO pro
D. relational databases
Answer optionb
Marks: 2
456 Which of the following are interfaces in javax.servlet.http package?
A. HttpServletRequest
B. HttpServletResponse
C. HttpSession
D. All of the above
Answer optiond
Marks: 1
Which of the following informs an object that it is bound to or unboun
457 session?
A. HttpServletRequest
B. HttpServlet
C. HttpSession
D. HttpSessionBindingListener
Answer optiond
Marks: 1
458 -----------------provides a way to identify a user across more than on
visit to a Web site and to store information about that user.
A. HttpServletRequest
B. HttpServlet
C. HttpSession
D. HttpSessionBindingListener
Answer optionc
Marks: 1
459 ------------------- class provides methods to handle HTTP requests an
A. HttpServlet
B. GenericServlet
C. HttpSessionEvent
D. None of the above
Answer optiona
Marks: 1
Which type of driver converts JDBC calls into network protocol used by
460 management system directly?
A. Type 1
B. Type 2
C. Type 3
D. Type 4
Answer optiond
Marks: 1
461 Which JDBC driver types can be used either in applet or servlet code?
A. Both Type 1 and Type 2
B. Both Type 1 and Type 3
C. Both Type 3 and Type 4
D. Type 4 only
Answer optionc
Marks: 2
462 How many JDBC driver types does Sun define?
A. 1
B. 2
C. 3
D. 4
Answer optiond
Marks: 1
463 String[] getSelectedItems() is the method of _________ class.
A. List
B. Choice
C. Button
D. TextArea
Answer optiona
Marks: 1
464 ______class is used to create radiobutton in AWT.
A. List
B. Choice
C. Checkbox
D. CheckboxGroup
Answer optiond
Marks: 1
465 __________ is used when user wants to enter text that is not displayed
A. setEditable()
B. setEchoChar()
C. getSelectedText()
D. setText()
Answer optionb
Marks: 1
466 Which of the following is correct statement? Consider t1 as TextField
A. t1.setEchoChar('*');
B. t1.setEchoChar("*");
C. t1.setEchoChar('**');
D. None of these
Answer optiona
Marks: 1
467 To create radiobutton in Applet which of the following are valid stat
CheckboxGroup cbg=new CheckboxGroup(); Checkbox cb1=new Checkbox("java
A. Checkbox cb2=new Checkbox("php",true,cbg);
CheckboxGroup cbg=new CheckboxGroup(); Checkbox cb1=new Checkbox("java
B. Checkbox cb2=new Checkbox("php",false,cbg);
CheckboxGroup cbg=new CheckboxGroup(); Checkbox cb1=new Checkbox("java
C. Checkbox cb2=new Checkbox("php",false,cbg);
D. All of above
Answer optiond
Marks: 2
468 Which is the correct statement to produce following output ?
A. List l1=new List(4);
B. List l1=new List(3,true);
C. List l1=new List(3,false);
D. List l1=new List();
Answer optionb
Marks: 2
In the Delegation Event Model, a user interface element is able to del
469 processing of an event............................
A. a separate piece of code
B. A source generates an event
C. a separate elements in a graphical user interface
D. None of above
Answer optiona
Marks: 1
470 In The delegation Event Model, ................
A. an Event propogated up the containment hierarchy
B. a source generates an event and sends it to one or more listeners.
C. notification sent to all components in containment hierarchy.
D. None of Above
Answer optionb
Marks: 1
Which of the following classes in Java contains swing version of an ap
471
A. JButton
B. JApplet
C. AbstractButton
D. JLabel
Answer optionb
Marks: 1
Which of the following value is not available to align arguments to u
472 Constants interface?
A. Left
B. Right
C. Middle
D. Leading
Answer optionc
Marks: 1
Which of the following classes of Java swing extends Applet class?
473
A. JButton
B. JApplet
C. AbstractButton
D. None of these
Answer optionb
Marks: 1
In Java swing, which of the following components is/are represented by
474 in which a component may be viewed?
A. Scroll pane
B. Tabbed pane
C. Combo boxes
D. None of these
Answer optiona
Marks: 2
Swing components are ultimately derived form which of the following ?
475
A. javax.awt.*
B. java.awt.*
C. javax.swing.JComponent
D. java.swing.*
Answer optionc
Marks: 1
Identify the layout manager for the given output container having a r
476 that should all be displayed at the same size, filling the container's
A. Grid Layout
B. Card Layout
C. Border Layout
D. Flow Layout
Answer optiona
Marks: 2
Swing components are preceded by the letter
477
A. S
B. A
C. X
D. J
Answer optiond
Marks: 1
478 The syntax for creating and setting layout manager object is----------
A. LayoutManager Obj= new LayoutManager();
B. LayoutManager Obj= new LayoutManager(); setLayout(Obj);
C. setLayout(Obj); LayoutManager Obj= new LayoutManager();
D. setLayout(Obj);
Answer optionb
Marks: 1
479 The Swing is an API for providing graphical user interface for
A. Python programs
B. Java programs
C. C programs
D. PHP programs
Answer optionb
Marks: 1
480 An Event can be generated by-
A. Pressing a button
B. A counter exceeds a value
C. cliking the Mouse
D. All of the above.
Answer optiond
Marks: 1
481 A general form, event registration method-
A. public void addTypeListener (TypeListener el)
B. public void addEventObject(EventObject eo)
C. public void addActionEvent(ActionEvent ae)
D. public void addComponetEvent(ComponentEvent ce)
Answer optiona
Marks: 1
Listeners are created by implementing one or more of the _____________
482 java.awt.event package.
A. class
B. interfaces
C. object
D. package
Answer optionb
Marks: 1
import javax.swing.*;
import java.awt.*;
--------------------------------------------------
public class FlowLayoutDemo extends JApplet {
public void init() {
Container cp = getContentPane();
483 -------------------------------
JButton button1 = new JButton("Button1");
JButton button2 = new JButton(" Button2");
JButton button3 = new JButton(" Button3");
cp.add(button1);
cp.add(button2);
cp.add(button3);
}
}
Identify the missing statement to get the following output.
A. <applet code="FlowLayoutDemo" width=100 height=100></applet>
B. <applet code="FlowLayoutDemo" width=100 height=100></applet> cp.setLay
<applet code="FlowLayout" width=100 height=100></applet> cp.setLayout(
C. );
<applet code="FlowLayoutDemo" width=100 height=100></applet> cp.setLay
D. FlowLayout() );
Answer optiond
Marks: 2
484 At The root of the java event class hierarchy is...............
A. ContainerEvent
B. ComponentEvent
C. WindowEvent
D. EventObject
Answer optiond
Marks: 1
Match the correct pairs-
a. getSource( ) i. Determine the type of the
485 b. toString ( ) ii. Returns the source of
c. getID( ) iii- Constructor
d. EventObject(Object src) iv- returns the string equivalent of th
A. c-i , a-ii, d-iii, b-iv
B. c-ii , a-i, d-iv, b-iii
C. c-iii , a-ii, d-i, b-iv
D. c-iv , a-iii, d-ii, b-i
Answer optiona
Marks: 2
486 An ActionEvent is generated -
A. a button is pressed, component gains or losses keyboard focus, scroll
B. a button is pressed, scroll bar is manipulaed, menu item is selected.
C. a button is pressed, input received from the keyboard, window is activ
D. a button is pressed, a list item is double-clicked, menu item is selec
Answer optiond
Marks: 1
487 The method getWhen( ) returns-
A. a value that indicates which modifier keys pressed.
B. the time at which the event took place.
C. obtain the command name for the invoking ActionEvent object.
D. reference to the object that generated event.
Answer optionb
Marks: 1
488 Which of these are integer constants defined in ActionEvent class-
A. ALT_MASK
B. META_MASK
C. SHIFT_MASK
D. All of the mentioned
Answer optiond
Marks: 1
489 Which components of AWT are used to produce following output.
A. TextArea,Label,Button
B. Label,Choice,Button
C. List,TextField,Button
D. List,Label,TextArea
Answer optionc
Marks: 1
Select proper output for following..
import java.awt.*;
import java.applet.*;
public class list extends Applet
{
public void init()
{
Button b1=new Button("OK");
List l=new List(5,true);
TextField t1=new TextField("Languages used");
CheckboxGroup cbg=new CheckboxGroup();
Checkbox c1,c2;
490 c1=new Checkbox("Server Side",true,cbg);
c2=new Checkbox("Client Side",false,cbg);
l.add("java");
l.add("php");
l.add("c++");
l.add("c");
l.add("Python");
add(l);
add(t1);add(b1);add(c1);add(c2);
}}
/*<applet code=list.class height=200 width=200>
</applet>*/
A.
B.
C.
D.
Answer optiona
Marks: 2
491 We cannot alter text in TextField when___
A. setEditable(true)
B. setEditable(false)
C. isEditable()
D. All of Above
Answer optionb
Marks: 1
492 ____method is used to lock the textfield component
A. getText()
B. setText()
C. getSelectedText()
D. setEditable(false)
Answer optiond
Marks: 1
493 which is constructor of Checkbox()?
A. Checkbox(String label)
B. Checkbox(String label,boolean state)
C. Checkbox(String label,boolean state,CheckboxGroup group)
D. All of Above
Answer optiond
Marks: 1
494 Following are the method(s) of List class
A. getSelectedIndex()
B. getSelectedIndexes()
C. getSelectedItem()
D. All of Above
Answer optiond
Marks: 1
495 Which of the following method does not belongs to Choice class.
A. getItem()
B. getSelectedIndexes()
C. getSelectedItem()
D. All of Above
Answer optionb
Marks: 1
496 Â Which of these interfaces define a method actionPerformed()?
A. ComponentListener
B. ContainerListener
C. ActionListener
D. InputListener
Answer optionc
Marks: 1
497 setSelectedCheckbox() is the method of ________
A. Checkbox
B. CheckboxGroup
C. List
D. RadioButton
Answer optionb
Marks: 1
498 TextArea supports _____method(s) of TextComponent class
A. select()
B. isEditable()
C. getText()
D. All of above
Answer optiond
Marks: 1
499 Which of these are methods of MouseListener Interface?
A. mouseDragged()
B. MouseMotionListener()
C. MouseClick()
D. MousePressed()
Answer optiond
Marks: 1
What does following line of code do ?
500 TextField text=new TextField(30);
A. Creates text object with 30 rows of text
B. Creates text object and initilizes with value 30
C. Creates text object with 30 columns of text
D. This is invalid code
Answer optionc
Marks: 1
501 How many ways can we align the label in a container ?
A. 1
B. 2
C. 3
D. 4
Answer optionc
Marks: 1
502 AWT includes multiline editor called as ______
A. TextField
B. Label
C. Button
D. TextArea
Answer optiond
Marks: 1
503 Which are the active controls that support any interaction with the us
A. Choice
B. List
C. Button
D. All of Above
Answer optiond
Marks: 1
1.import java.awt.*;
2.import java.applet.*;
3.public class ChoiceDemo extends Applet
4.{
5. public void init()
6. {
7. Button b1=new Button("OK");
8. Choice l=new Choice();
9. l.add("java");
10. l.add("php");
504 11. l.add("c++");
12. l.add("c",true);
13. l.add("Python");
14. add(l);
15. add(b1);
16.}}
17.
18./*<applet code=choice.class height=200 width=200>
19.</applet>*/
Which statement number shows compilation error ?
A. 7.Button b1=new Button("ok");
B. 8.Choice l=new Choice();
C. 12.l.add("c",true);
D. No Compilation Error in given code
Answer optionc
Marks: 2
import java.awt.*;
import java.applet.*;
public class choiceDemo extends Applet
{
public void init()
{
Button b1=new Button("OK");
Choice l=new Choice();
Label lb=new Label("List");
add(lb);
505 l.add("java");
l.add("php");
l.add("c++");
l.add("c");
lb.add("Python");
add(l);
add(b1);
}}
/*<applet code=choice.class height=200 width=200>
</applet>*/
Which is incorrect statement ?
A. Label lb=new Label("List");
B. add(b1);
C. lb.add("Python");
D. None of above
Answer optionc
Marks: 2
import java.awt.*;
import java.applet.*;
506 public class textareaex extends Applet
{
public void init()
{
TextField t2=new TextField("welcome",20,40);
TextArea t1=new TextArea(10,30);
add(t1);add(t2);
}}
/*<applet code=textareaex.class height=200 width=200>
</applet>*/
Which statement will give an error ?
A. TextArea t1=new TextArea(10,30);
B. TextField t2=new TextField("welcome",20,40);
C. public class textareaex extends Applet
D. add(t1);add(t2);
Answer optionb
Marks: 2
507 An ItemEvent is generated when............................
A. user clicked the mouse
B. keyboard input occurs.
C. a checkable menu item is selected or deselected.
D. The window was activated.
Answer optionc
Marks: 1
508 The Swing was previously known as
A. Java shoot
B. Java control
C. Java Class
D. Java Foundation Class
Answer optiond
Marks: 1
509 Swing is an excellent replacement for
A. Abstract Window Toolkit (AWT)
B. Java control
C. Java drive
D. Java class
Answer optiona
Marks: 1
510 The following are advanced components that comes with Swing except
A. Trees
B. Lists
C. Graph
D. Table
Answer optionc
Marks: 2
511 Swing components are referred to as platform-independent and thus desc
A. Heavyweight
B. Elements
C. Lightweight
D. Light Components
Answer optionc
Marks: 1
512 In Java Swing, the JTable has a model called
A. JModel
B. TableModel
C. JRule
D. JSwing
Answer optiond
Marks: 1
select the correct output for following code
import javax.swing.*;
public class FirstSwingExample {
public static void main(String[] args) {
JFrame f=new JFrame();//creating instance of JFrame
JButton b=new JButton("click");//creating instance of JButton
b.setBounds(130,100,100, 40);//x axis, y axis, width, height
513
f.add(b);//adding button in JFrame
f.setSize(400,500);//400 width and 500 height
f.setLayout(null);//using no layout managers
f.setVisible(true);//making the frame visible
}
}
A.
B.
C.
D.
Answer optionc
Marks: 2
select the correct output for following code
import javax.swing.*;
class LabelExample
{
public static void main(String args[])
514 {
JFrame f= new JFrame("Label Example");
JLabel l1,l2;
l1=new JLabel("First Label.");
l1.setBounds(50,50, 100,30);
l2=new JLabel("Second Label.");
l2.setBounds(50,100, 100,30);
f.add(l1); f.add(l2);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
}
A.
B.
C.
D. None of the above
Answer optionc
Marks: 2
-------------- is the class representing event notifications for chang
515 within a web application.
A. HttpServlet
B. Cookie
C. HttpSessionEvent
D. None of the above
Answer optionc
Marks: 1
Which of the following method call can be used to send an error respo
516 using the specified integer 'statusCode' and String error message 'mes
A. request.sendError(statusCode,message)
B. response.sendError(statusCode,message)
C. header.sendError(statusCode,message)
D. None of the above
Answer optionb
Marks: 1
_______method of HttpServletResponse interface can be used to redirect
517 another resource, it may be servlet, jsp or html file.
A. sendRedirect()
B. sendError()
C. Redirect()
D. None of the above
Answer optiona
Marks: 1
518 Which methods are used to bind the objects on HttpSession instance and
A. setAttribute() only
B. getAttribute() only
C. Both A and B
D. None of the above
Answer optionc
Marks: 1
519 getAuthType() returns the name of the _______used to protect the servl
A. authentication scheme
B. authority Scheme
C. Authorization scheme
D. none of above
Answer optiona
Marks: 1
520 ____ returns an enumeration of the header names
A. getHeaderNames()
B. getNames()
C. getHeader()
D. none of the above
Answer optiona
Marks: 1
521 _______ method returns the part of this request's URL that calls the
A. getServletPath()
B. getPathInfo()
C. getPathTranslated()
D. None of the above
Answer optiona
Marks: 1
Which of the following is not a method of HttpServletRequest interface
522
A. isRequestedSessionIdFromCookie( )
B. getHeader(String field )
C. getMethodI( )
D. addCookie(Cookie cookie)
Answer optiond
Marks: 1
523 Which class provides system independent server side implementation?
A. Socket
B. ServerSocket
C. Server
D. ServerReader
Answer optionb
Marks: 1
------------Determines if the session ID must be encoded in the URL id
524 so, returns the modified version of url. Otherwise, returns url.
A. encodeRedirectURL(String url)
B. String encodeURL(String url)
C. encode(String url)
D. None of the above
Answer optionb
Marks: 1
________ returns a boolean indicating whether the named response head
525 set.
A. void containsHeader(String name)
B. boolean containsHeader(String name)
C. boolean containsHeader()
D. Boolean isHeader(String name)
Answer optionb
Marks: 1
526 Following Shows networking terminologies ?
A. IP Address
B. Protocol
C. URL
D. All of the above
Answer optiond
Marks: 1
________ returns true if the server created the session and it has not
527 by the client.
A. invalidate( )
B. isNew()
C. getLastAccessedTime( )
D. None of the above
Answer optionb
Marks: 1
528 Invalidate() method belongs to ______interface
A. SessionBindingListener
B. HttpSessionBindingListener
C. HttpBindingListener
D. HttpListener
Answer optionb
Marks: 1
______ interface is implemented by objects that need to be notified wh
529 to or unbound from an HTTP session.
A. SessionBindingListener
B. HttpSessionBindingListener
C. HttpBindingListener
D. HttpSessionBinding
Answer optionb
Marks: 1
530 Cookies are stored at _____ side.
A. server
B. client
C. Both A and B
D. Neither A nor B
Answer optionb
Marks: 1
531 Some of the information that is saved for each cookie includes the fol
A. The name of the cookie
B. The value of the cookie
C. The expiration date of the cookie
D. All of the above
Answer optiond
Marks: 1
---------------returns true if the browser is sending cookies only ove
532 protocol, or false if the browser can send cookies using any protocol.
A. getSecure( )
B. getName( )
C. clone()
D. None of these
Answer optiona
Marks: 1
533 The HttpServlet class extends ______
A. GenericServlet
B. Servlet
C. Throwable
D. none of the above
Answer optiona
Marks: 1
534 Which of the following is not a method of HttpServlet class?
A. doDelete()
B. doGet()
C. doHead()
D. getValue()
Answer optiond
Marks: 1
535 Which method is Called by the server when an HTTP request arrives for
A. getLastModified()
B. service()
C. init()
D. None of the above
Answer optiond
Marks: 1
536 HttpSessionEvent encapsulates ______Object
A. Event
B. session
C. request
D. response
Answer optiona
Marks: 1
537 _____ returns the name of the cookie.
A. getName()
B. getName(String s)
C. getName(String s,String a)
D. none of the above
Answer optiona
Marks: 1
---------returns the current session associated with this request, or
538 not have a session, creates one.
A. getName()
B. getSession()
C. getSessionName()
D. putSession()
Answer optionb
Marks: 1
539 A servlet developer overrides which of the following methods?
A. doDelete()
B. doGet()
C. doHead()
D. All of the above
Answer optiond
Marks: 1
Identify Error in the following servlet code
import java.io.*;
public class ColorGetServlet extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse resp
ServletException, IOException {
540 String color = request.getParameter("color"); response.setContentType(
PrintWriter pw = response.getWriter(); pw.println("<B>The selected col
pw.println(color);
pw.close();
}
}
A. javax.servlet.http.* ;is missing
B. javax.servlet.*; is missing
C. Both A and B
D. None of the above
Answer optionc
Marks: 2
541 Which classes are used for connection-oriented socket programming?
A. Socket
B. ServerSocket
C. Both A and B
D. None of the above
Answer optionc
Marks: 1
542 The ______is invoked when a form on a Web page is submitted.
A. servlet
B. session
C. cookie
D. none of above
Answer optiona
Marks: 1
Find error in the following code
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ColorPostServlet extends HttpServlet
{
public void doPost(HttpServletRequest request,HttpServletResponse res
ServletException, IOException
543 {
String color = request.getParameter("color");
PrintWriter pw = response.getWriter();
pw.println("<B>The selected color is: ");
pw.println(color);
pw.close();
}
}
A. Some classes/ interfaces not imported
B. Correct Exception is not thrown by the method
C. No Error
D. response.setContentType("text/html"); is missing
Answer optiond
Marks: 2
Which is a one-way communication only between the client and the serve
544 reliable and there is no confirmation regarding reaching the message t
A. TCP/IP
B. UDP
C. Both A & B
D. None of the above
Answer optionb
Marks: 1
545 Which method returns copy of this cookie object?
A. getclone()
B. clone()
C. setclone()
D. None of these
Answer optionb
Marks: 1
546 Which class allows state information to be stored on a client machine?
A. Cookie
B. HttpServlet
C. HttpSession
D. None of these
Answer optiona
Marks: 1
547 getCookies() method returns ______ of the cookies in this request
A. array
B. enum
C. object
D. none of the above
Answer optiona
Marks: 1
548 Which method returns the URL?
A. getURL()
B. URL()
C. getRequestURL()
D. None of the above
Answer optionc
Marks: 1
549 ______ returns true if a cookie contains session id otherwise false
A. isRequestedSessionFromCookie()
B. isRequestedFromCookie()
C. isRequestedSessionCookie()
D. None of the Above
Answer optiona
Marks: 1
______ method returns true if requested session ID is valid in the c
550 context
A. isRequestedSessionIdValid()
B. isSessionIdValid()
C. isRequestedIdValid()
D. RequestedSessionIdValid()
Answer optiona
Marks: 1
551 Which method redirects the client to the URL?
A. sendRedirect(String url)
B. Redirect(String url)
C. sendError(String url)
D. None of the above
Answer optiona
Marks: 1
552 ____ method adds field to the header with date value equal to msec?
A. void setDateHeader(String field,long msec)
B. void DateHeader(String field,int msec)
C. void setDateHeader(long msec)
D. void setDate(String field,long msec)
Answer optiona
Marks: 1
553 Which method sets status code for this response to code
A. void setStatus(int code)
B. void setStatus()
C. void Status(int code)
D. None of the above
Answer optiona
Marks: 1
554 Which method returns the time when the client last made a request for
A. void getLastAccessDate()
B. long getLastAccessedTime()
C. getAccessedTime()
D. None of the above
Answer optionb
Marks: 1
555 Which method performs an HTTP DELETE?
void doDelete(HttpServletRequest req,HttpServletResponse res) throws I
A. ServletException
void Delete(HttpServletRequest req,HttpServletResponse res) throws IOE
B. ServletException
void destroy(HttpRequest req,HttpServletResponse res) throws IOExcepti
C. ServletException
D. void doDestroy(HttpRequest req,HttpResponse res) throws IOException, S
Answer optiona
Marks: 1
556 Which method performs an HTTP GET?
A. void Get(HttpServletRequest req,HttpServletResponse res) throws Servl
void doGet(HttpServletRequest req,HttpServletResponse res) throws IOEx
B. ServletException
void DoGet(HttpServletRequest req,HttpServletResponse res) throws IOEx
C. ServletException
D. None of the above
Answer optionb
Marks: 1
557 _____ method invalidates this session and removes it from the context?
A. void invalidate()
B. void validate()
C. void verify()
D. void removeAttribute()
Answer optiona
Marks: 1
558 _________ method removes attribute specified by attr from the session.
A. void removeAttribute(String attr)
B. void removeAttribute()
C. void deleteAttribute(String attr)
D. void remove()
Answer optiona
Marks: 1
559 Which of the following is not a method of HttpSession interface?
A. getAttribute()
B. setAttribute()
C. setHeader()
D. isNew()
Answer optionc
Marks: 1
560 All the methods of _____Interface throw IllegalStateException
A. Session
B. HttpSession
C. cookies
D. Servlet
Answer optionb
Marks: 1
561 Which of the following is true about cookies?
A. Cookies are stored on client
B. Cookies contain state information
C. Cookies track user activities
D. All of the above
Answer optiond
Marks: 1
562 Which one is not a constructor for cookie?
A. Cookie() only
B. Cookie(String name) only
C. a and b
D. Cookie(String name,String value)
Answer optionc
Marks: 1
563 If an expiration date is not explicitly assigned to a cookie,it is del
A. Immediately after creation
B. When session is expired
C. when current browser session ends.
D. Never
Answer optionc
Marks: 1
564 Which of the following is not a method of cookie class?
A. Clone()
B. getMaxAge()
C. doGet()
D. getName()
Answer optionc
Marks: 1
565 Which of the following are methods of HttpServlet Class?
A. setComment()
B. doDelete() only
C. doGet() only
D. b and c
Answer optiond
Marks: 1
566 HttpServlet class methods throw _______.
A. IOException only
B. ServletException only
C. IllegalstateException only
D. IOException and ServletException only
Answer optiond
Marks: 1
567 Which of the following is constructor for HttpSessionEvent Class?
A. HttpSessionEvent()
B. HttpSessionEvent(Httpsession session)
C. HttpSessionEvent(String value)
D. None of the above
Answer optionb
Marks: 1
568 httpServlet program overrides ____ method
A. doPut() only
B. doHead() only
C. doTrace()
D. All Of The Above
Answer optiond
Marks: 1
569 _____ and _____ requests are most commonly used when handling form in
A. get , post
B. put , trace
C. head , delete
D. none of above
Answer optiona
Marks: 1
570 ____ identifies a servlet to process HTTP GET request
A. session
B. cookie
C. URL
D. request
Answer optionc
Marks: 1
Parameters of ____ request are included as part of the URL that is sen
571 Server.
A. HTTPPOST
B. HTTPGET
C. HTTPDELETE
D. HTTPTRACE
Answer optionb
Marks: 1
------------ method returns true if the cookie contains session id.oth
572 false
A. Boolean isRequestedSessionIdFromCookie()
B. Boolean isRequestedSessionId()
C. Boolean isSessionIdFromCookie()
D. None of the above
Answer optiona
Marks: 1
---------method returns any extra path information associated with th
573 sent when it made this request.
A. String getPathInfo()
B. String getPath()
C. String getMethod()
D. None of the above
Answer optiona
Marks: 1
574 ------------- returns an array of the cookies in this request
A. Cookie[] getCookies()
B. Cookie[] getMaxCookies()
C. Cookie[] getMinCookies()
D. None of the above
Answer optiona
Marks: 1
575 Which method returns int equivalent of the header field named field?
A. int getHeader()
B. int getIntHeader()
C. int getIntHeader(String field)
D. None of these
Answer optionc
Marks: 1
576 ---------- method returns name of the user who issues this request.
A. String getRemoteUser()
B. String getUser()
C. String getRemote()
D. None of these
Answer optiona
Marks: 1
577 Which method adds cookie to the HTTP response
A. void addCookie()
B. void addCookie(Cookie cookie)
C. void addCookie(String cookie)
D. void addCookie(int i)
Answer optionb
Marks: 1
578 _____ sets status code for this response to code
A. setStatus()
B. setStatus(int code)
C. setStatusCode(int code)
D. None of the Above
Answer optionb
Marks: 1
579 Cookies were originally designed for __________
A. Client-side programming
B. Server-side programming
C. Both Client-side & Server-side programming
D. web programming
Answer optionb
Marks: 1
580 ----is not a protocol
A. Telnet
B. TCP
C. FTP
D. hit
Answer optiond
Marks: 1
581 Following are tasks of Proxy Server__________
A. Filter certain request
B. cache the results of request for future use
C. provide faster access of catched pages to clients
D. All of the above
Answer optiond
Marks: 1
582 Select incorrect statement about Internet Protocol
A. It is low level routing Protocol
B. It breaks data into small packets
C. sends packet to an address across network
D. it is higher level Protocol
Answer optiond
Marks: 1
583 Canvas is a ______________
A. Window
B. Frame
C. Panel
D. applet
Answer optiona
Marks: 1
By default page-up and page-down increment of scrollbar is____________
584
A. 20
B. 10
C. 15
D. 5
Answer optionb
Marks: 1
585 Scrollbar( ) creates a ______________ scroll bar by default.
A. Vertical
B. Horizantal
C. Both
D. None
Answer optiona
Marks: 1
----- is the protocol that web browser and server use to transfer hype
586 images
A. FTP
B. HTTP
C. telnet
D. none of above
Answer optionb
Marks: 1
587 Which of the following are various AWT controls?
A. Labels, Push buttons, Check boxes, Choice lists.
B. Text components, Threads, Strings, Servelts, Vectors
C. Labels, Strings, JSP, Netbeans, Sockets
D. Push buttons, Servelts, Notepad, JSP
Answer optiona
Marks: 1
588 To execute a statement, we invoke method
A. execute method
B. executeRel method
C. executeStmt method
D. executeConn method
Answer optiona
Marks: 1
A typical __________ program obtains a remote reference to one or more
589 a server and then invokes methods on them.
A. server
B. client
C. thread
D. concurrent
Answer optionb
Marks: 1
590 File transfer protocol(FTP) is used for____________
A. Speed
B. Efficient
C. Security
D. All of the above
Answer optiond
Marks: 1
Which of these class is necessary to implement datagrams?
591
A. DatagramPacket
B. DatagramSocket
C. All of the mentioned
D. None of the mentioned
Answer optionc
Marks: 1
The Prepared statement _____symbolis a placeholder that is replaced by
592 parameter at seen time
A. ?
B. *
C. /
D. +
Answer optiona
Marks: 1
593 Which methods are commonly used in ServerSocket class?
A. public OutputStream getOutputStream()
B. public synchronized void close()
C. public Socket accept()
D. none of the above
Answer optionc
Marks: 1
594 The ___________method is used to insert data into table
A. execute()
B. executeQuery()
C. executeUpdate()
D. None of the above
Answer optionc
Marks: 1
595 Which method is used to load the driver?
A. Class.forName()
B. class.forname()
C. Connection con
D. None of the above
Answer optiona
Marks: 1
596 A small data file in the browser.
A. Cookie
B. Web Server
C. FTP
D. DATABASE
Answer optiona
Marks: 1
Unlike User Datagram Protocol (UDP), Transmission Control Protocol (TC
597 which is
A. Connection Oriented
B. Connectionless
C. Connection Available
D. Connection Origin
Answer optiona
Marks: 1
Unlike Transmission Control Protocol (TCP), User Datagram Protocol (UD
598 which is
A. Connection Oriented
B. Connectionless
C. Connection Available
D. Connection Origin
Answer optionb
Marks: 1
599 The JDBC-ODBC Bridge driver translates the JDBC API and used with ____
A. JDBC drivers
B. ODBC drivers
C. Both A and B
D. None of the above
Answer optionb
Marks: 1
600 Which protocol is for breaking and sending packets to an address acros
A. UDP
B. TCP/IP
C. Proxy server
D. none of the above
Answer optionb
Marks: 1
Consider the following code. What will be student table data after exe
table has only one record.
import java.sql.*;
public class MyDB
{
public static void main(String[] args) throws Exception
{
601 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:mystud");
PreparedStatement ps = con.prepareStatement("delete * from student");
ps .executeUpdate(); Statement st = con.createStatement(); ResultSet R
ps.executeQuery("select * from student");
while (Rset.next()) { int studid = Rset.getInt("rno");
String studname = Rset.getString("name");
System.out.println(studid + " " +studname); } } }
A. One record will get displayed.
B. No record will get displayed.
C. All records will get displayed.
D. None of the above.
Answer optionb
Marks: 2
602 The __________object allows you to execute parametrized queries
A. putString()
B. insertString()
C. setString()
D. setToString()
Answer optionc
Marks: 1
603 UDP stands for ---------
A. User Datagram Protocol
B. Uses Datagram Protocol
C. user data procedure
D. user data program
Answer optiona
Marks: 1
Central Computer which is powerful than other computers in the network
604 __________.
A. client
B. server
C. hub
D. switch
Answer optionb
Marks: 1
605 which class is used to create servers that listen for either local or
A. Server Machine
B. Client Machine
C. HttpServer
D. ServerSockets
Answer optiond
Marks: 1
606 The class java.sql.Timestamp is associated with _______
A. java.util.time
B. java.sql.Time
C. java.util.Date
D. None of the above
Answer optionc
Marks: 1
Fill in the blank space?
import java.sql;
class connectDB
{
607 public static void main(String arg[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver Loaded");
String url="jdbc:odbc:myDCN");
Connection con=__________.getConnection(url);
System.out.println("Connection to database is created");
}
catch(SQLException e)
{
System.out.println("Error"+e);
}
catch(Exception e)
{
system.out.println("Error"+e);
}
}
}
}
A. DriverManager
B. classmanager
C. statementmanager
D. None of the above
Answer optiona
Marks: 2
608 Which are the navigation methods of resultset?
A. beforeFirst()
B. afterLast()
C. first()
D. All of the above
Answer optiond
Marks: 1
__________method is used to execute the queries that contains the INSE
609 UPDATE statements.
A. execute()
B. executeQuery()
C. executeUpdate()
D. getResultSet()
Answer optionc
Marks: 2
610 Which of the following query is use for select query?
A. execute()
B. execute(String sql)
C. executeUpdate(String sql)
D. executeQuery(String sql)
Answer optiond
Marks: 1
611 _________ method of HttpServletResponse interface adds cookies to the
A. public void addCookie(Cookie cookie )
B. public void addCookie( )
C. public void getCookie(Cookie cookie )
D. public void getCookie( )
Answer optiona
Marks: 1
612 HTTP stands for___________?
A. Hypertext transfer processor
B. Hypertext Transfer Protocol
C. High transfer protocol
D. hyper transfer protocol
Answer optionb
Marks: 1
_______method from JDBC is the means of establishing a connection betw
613 Database.
A. getConnection()
B. executeQuery()
C. createStatement()
D. executeUpdate()
Answer optiona
Marks: 1
A servlet can write a cookie to a user's machine via the addCookie( )
614 _____________ interface
A. ServletRequest
B. HttpServletRequest
C. HttpServletResponse
D. ServletResponse
Answer optionc
Marks: 1
615 Which driver converts JDBC API calls into DBMS-specific client API cal
A. Type 1
B. Type 2
C. Type 3
D. Type 4
Answer optionb
Marks: 1
616 Correct syntax of the constructor to create Cookie object is____:
A. Cookie(String value, String name)
B. Cookie(int value, String name)
C. Cookie(String name, String value)
D. Cookie(int value, int name)
Answer optionc
Marks: 1
which driver converts JDBC API calls directly into the DBMS specific n
617 without a middle tier?
A. Type 1
B. Type 2
C. Type 3
D. Type 4
Answer optiond
Marks: 1
618 Information that is saved for each cookie includes ______
A. The name, the value and expiration date of the cookie.
B. The name and expiration date of the cookie only
C. The name of Cookie only.
D. The name and the value of the cookie only
Answer optiona
Marks: 1
which driver converts JDBC API calls middle tier net server that trans
619 into the DBMS specific network protocol ?
A. Type 1
B. Type 2
C. Type 3
D. Type 4
Answer optionc
Marks: 1
620 Which driver allows access to multiple databases using one driver?
A. Type 1
B. Type 2
C. Type 3
D. Type 4
Answer optionc
Marks: 1
621 Following is the correct syntax for creating Cookies Object c .
A. Cookie c = new Cookie(MyCookie, data);
B. Cookie c = new Cookie("MyCookie", data);
C. cookie c = new cookie("MyCookie", data);
D. Cookie c = new Cookie(data,"MyCookie");
Answer optionb
Marks: 1
622 The Elements Of Flow Layouts are arranged in --------------------fash
A. stacked, on the top of the other
B. laid out using the square of a grid
C. Organized top to bottom, left to right
D. organized at the borders and the centre of a container
Answer optionc
Marks: 1
623 which method returns the current result as Resultset object.
A. execute()
B. executeQuery()
C. getResult()
D. getResultSet()
Answer optiond
Marks: 1
624 Which method executes the given SQL statement , which return the singl
A. execute()
B. executeQuery()
C. executeUpdate()
D. getResultSet()
Answer optionb
Marks: 1
625 What is the Difference Between Grid And Gridbaglayout?
In Grid layout the size of each grid is varying where as in GridbagLay
A. constant.
In Grid layout the size of each grid is constant where as in GridbagLa
B. be varied.
C. The size of each component in both layout is same
D. All of the above
Answer optionb
Marks: 1
626 _______ method is called when servlet is initialized.
A. destroy()
B. service()
C. init()
D. connect()
Answer optionc
Marks: 1
627 Which driver provides JDBC access via one or more ODBC drivers
A. Type 1 driver
B. Type 2 driver
C. Type 3 driver
D. Type 4 driver
Answer optiona
Marks: 1
628 To iterate the resultset you use its _________ method
A. next()
B. previous()
C. beforefirst()
D. afterLast()
Answer optiona
Marks: 1
629 A servlet is an instance of ___________
A. HTTPServlet class
B. Cookie
C. HttpSessionBindingEvent
D. HttpUtils
Answer optiona
Marks: 1
Which of the following method is used to Sets the maximum age of th
630 seconds.
A. public void setmaxage(int secs)
B. public void Setmaxage(String secs)
C. public void setMaxAge(String secs)
D. public void setMaxAge(int secs)
Answer optiond
Marks: 1
When iterating the ResultSet you want to access the column values of e
631 so by calling one or more of the many ______ methods.
A. getXXX()
B. updateXXX()
C. setXXX()
D. None of the above
Answer optiona
Marks: 1
632 Which method moves the cursor to the first row of the resultset?
A. first()
B. last()
C. next()
D. previous()
Answer optiona
Marks: 1
633 Which method is called to process HTTP request?
A. destroy()
B. service()
C. init()
D. None of these
Answer optionb
Marks: 1
Which of the following method of HttpServletRequest interface is used
634 cookies from the browser.
A. Cookie getcookies()
B. private Cookie[] getCookies()
C. public Cookie[] getCookies()
D. public Cookie[] setCookies()
Answer optionc
Marks: 1
Which is correct for the Three Tier Architecture of JDBC?
635 i) It can connect to different databases without changing code
ii)Business logic is clearly separated from database.
A. only i
B. only ii
C. both
D. none
Answer optionc
Marks: 2
636 What Is A Layout Manager?
A. A layout manager is an object that is used to organize components in a
B. It is a container object.
C. It is a component object.
D. All of the above
Answer optiona
Marks: 1
637 getUserName() is used to
A. retrive name of the user
B. access name
C. Both of the above.
D. None of the above.
Answer optiona
Marks: 2
638 what are the components of Three Tier Architecture?
A. Client-Tier
B. Middle_Tier
C. Data Source Layer
D. All of the above
Answer optiond
Marks: 2
----------method indicates to the browser whether the cookie should o
639 secure protocol, such as HTTPS or SSL.
A. public void setSecure(boolean flag)
B. public void setsecure(int flag)
C. private void setSecure(boolean flag)
D. public boolean setSecure(boolean flag)
Answer optiona
Marks: 1
640 Which driver is known as Network Protocol, Pure Java Driver?
A. Type 1
B. Type 2
C. Type 3
D. Type 4
Answer optionc
Marks: 1
641 Which driver is known as Native Protocol, Pure Java Driver.?
A. Type 1
B. Type 2
C. Type 3
D. Type 4
Answer optiond
Marks: 1
642 Which method moves the cursor to the beginning of the resultset that i
A. beforeFirst()
B. afterLast()
C. first()
D. last()
Answer optiona
Marks: 1
643 Following method is used for setting up comments in the cookie.
A. public void setComment(int purpose)
B. public void setComment(String purpose)
C. public void getComment(String purpose)
D. private void setcomment(String purpose)
Answer optionb
Marks: 1
The server calls __________ method to relinquish any resources, such a
644 that are allocated for servlet.
A. service()
B. init()
C. destroy()
D. stop()
Answer optionc
Marks: 1
645 The life cycle of servlet is managed by ___________
A. servlet context
B. servlet container
C. servletconfig
D. All of the above
Answer optionb
Marks: 1
Which of the following method is used to specify the path to which
646 return the cookie.
A. public void setPath(String path)
B. public void setpath(String value)
C. public void setPath(int path)
D. private void setpath(String path)
Answer optiona
Marks: 1
647 The include() method of RequestDispatcher ______
A. Sends a request to another resource
B. Include the content of resource like servlet,jsp or html
C. Appends the request and response object to the current servlet
D. None of the above
Answer optionb
Marks: 1
Find the error in the following code
import java.io.*;
import javax.servlet.*;
public class HelloServlet extends GenericServlet{
public void service(ServletRequest request, ServletResponse response)
648 ServletException,IOException{
response.setContentType("text/html");
PrintWriter pw = response.getOutputStream();
pw.println("<b> Hello");
pw.close();
A. import javax.servlet.*;
B. response.setContentType("text/html")
C. PrintWriter pw = response.getOutputStream();
D. None of these
Answer optionc
Marks: 2
649 Which of the following method is used to Set the domain in which this
A. public void setDomain(String pattern)
B. public void setDomain(int pattern)
C. public void getDomain(String pattern)
D. private void setdomain(String pattern)
Answer optiona
Marks: 1
650 Which package contains the classes and interfaces required to build se
A. javax.servlet and javax.servlet.http
B. javax.servlet only
C. javax.servlet.http only
D. java.servlet and java.servlet.http
Answer optiona
Marks: 1
651 Which of the following method returns the cookie protocol version.
A. int getVersion( )
B. int setversion( )
C. int GetVersion( )
D. String getVersion( )
Answer optiona
Marks: 1
_______ class provides functionality that makes it easy to handle re
652 responses.
A. Generic Servlet
B. ServletInputStream
C. ServletOutputStream
D. None of these
Answer optiona
Marks: 1
653 Which of these classes implement the LayoutManager interface?
A. RowLayout
B. ColumnLayout
C. GridBagLayout
D. All of the above
Answer optionc
Marks: 1
654 _______method establishes the MIME type of the HTTP response.
A. setContentType()
B. ContentType()
C. setType()
D. none of above
Answer optiona
Marks: 1
655 ______ is a way to maintain state (data) of an user.
A. Session Tracking
B. Cookie tracking
C. HttpServletState
D. Session
Answer optiona
Marks: 1
656 Which of the following interface declares the lifecycle method for ser
A. Servlet
B. Servlet Config
C. ServletContext
D. ServletResponse
Answer optiona
Marks: 1
657 ____________encapsulates session events.
A. httpsessionevent
B. HttpSessionEvent
C. HttpSessionTrackingEvent
D. HttpSessionEventObject
Answer optionb
Marks: 1
658 ____________ interface allows servlet to get initialization parameters
A. SingleThreadModel
B. ServletRequest
C. ServletConfig
D. ServletContext
Answer optionc
Marks: 1
659 Which of the following method returns the session in which the event
A. HttpSession setSession( )
B. httpsession getsession( )
C. HttpSession getSession( )
D. HttpSession setSessionEvent( )
Answer optionc
Marks: 1
660 HTTP is a __________ protocol.
A. stateless
B. state oriented
C. stateful
D. none of above
Answer optiona
Marks: 1
How will the following program lay out its buttons. Select the one cor
import java.awt.*;
public class MyClass {
661 public static void main(String args[]) {
String[] labels = {"A","B","C","D","E","F"};
Window win = new Frame();
win.setLayout(new GridLayout(1,0,2,3));
for(int i=0;i < labels.length;i++)
win.add(new Button(labels[i]));
win.pack();
win.setVisible(true);
}
}
A. The program will not display any buttons.
B. The program will display all buttons in a single row.
C. The program will display all buttons in a single column.
D. The program will display three rows - A B, C D, and E F.
Answer optionb
Marks: 2
662 A session can be created via the getSession( ) method of __________.
A. HttpServletResponse
B. HttpServletRequest
C. HttpServlet
D. GenericServlet
Answer optionb
Marks: 1
663 ______method Writes the specified message to a servlet log file, usual
A. log(jString msg)
B. log()
C. Both A and B
D. none of above
Answer optiona
Marks: 1
664 JComboBox constructors are________________
A. JComboBox( )
B. JComboBox(Vector v)
C. JComboBox(Vector v,Vector v)
D. both a & b
Answer optiond
Marks: 1
In some applications, it is necessary to __________ so that informatio
665 from several interactions between a browser and a server.
A. save date and time information
B. save creation of session
C. save state information
D. save objects
Answer optionc
Marks: 1
666 A session can be created via the ___________ method of HttpServletRequ
A. getSessionCreate( )
B. setSession( )
C. setsession( )
D. getSession( )
Answer optiond
Marks: 1
667 Which Swing classes can be used with progress bars?
A. JProgressBar
B. ProgressMonitor
C. ProgressMonitorInputStream
D. all the above
Answer optiond
Marks: 1
How will the following program lay out its buttons. Select the one cor
import java.awt.*;
public class MyClass {
public static void main(String args[]) {
String[] labels = {"A"};
Window win = new Frame();
668 win.setLayout(new FlowLayout());
for(int i=0;i < labels.length;i++)
win.add(new Button(labels[i]));
win.pack();
win.setVisible(true);
}
}
A. The button A will appear on the top left corner of the window.
B. The button A will appear on the middle row and column, in the center
C. The button A will appear on the top right corner of the window.
D. The button A will appear on the top right corner of the window.
Answer optionb
Marks: 2
HttpSession hs = request.getSession(true);
669 Above statement indicates that_____
A. Get the HttpSession object
B. Get the Http object.
C. Set the HttpSession object.
D. Set the Cookie object.
Answer optiona
Marks: 1
What will be the output of the following code?
1. import java.io.*;
2. import java.util.*;
3. import javax.servlet.*;
4. import javax.servlet.http.*;
5 public class DateServlet extends HttpServlet {
6. public void doGet(HttpServletRequest request, HttpServletResponse
ServletException, IOException {
7. HttpSession hs = request.getSession(true);
8. response.setContentType(""text/html"");
670 9. PrintWriter pw = response.getWriter();
10. pw.print(""<B>"");
11. Date date = (Date)hs.getAttribute(""date"");
12. if(date != null) {
13. pw.print(""Last access: "" + date + ""<br>"");
14. }
15. date = new Date();
16. hs.setAttribute(""date"", date);
17. pw.println(""Current date: "" + date);
18. }
19. }
The first line shows the date and time when the servlet was last acces
A. line shows the current date and time.
B. shows the date and time when the servlet was last accessed.
C. shows the date and time when the servlet was last accessed
The first line shows the date and time when the servlet is first acces
D. line shows the previous date and time.
Answer optiona
Marks: 2
The ________ method is overridden to process any HTTP POST requests th
671 servlet.
A. doGet()
B. doPost( )
C. doPut()
D. doHead()
Answer optionb
Marks: 1
The ____________ method is overridden to process any HTTP GET requests
672 this servlet.
A. doPost( )
B. doPut()
C. doGet( )
D. doHead()
Answer optionc
Marks: 1
The doGet( ) method is overridden to process any ________ requests tha
673 servlet.
A. HTTP POST
B. HTTP SET
C. HTTP TRACE
D. HTTP GET
Answer optiond
Marks: 1
The doPost( ) method is overridden to process any _________requests th
674 servlet.
A. HTTP POST
B. HTTP SET
C. HTTP TRACE
D. HTTP GET
Answer optiona
Marks: 1
Suppose a JFrame uses the GridLayout(2,0). If six buttons are added t
675 many columns are displayed?
A. 1
B. 2
C. 3
D. 4
Answer optionc
Marks: 1
How many frames are c related ?
import java.awt.*;
import javax.swing.*;
public class FrameTest
{
public static void main(String args[])
{
676 JFrame fr=new JFrame("My frame");
JFrame fr1=fr;
JFrame fr2=fr1;
fr.setVisible(true);
fr1.setVisible(true);
fr2.setVisible(true);
}
}
A. 1
B. 2
C. 3
D. 0
Answer optiona
Marks: 2
677 ___________provide client request information to a servlet.
A. ServletResponse
B. ServletRequest
C. both a and b
D. None of these
Answer optionb
Marks: 1
678 The SingleThreadModel indicates that the __________ is thread safe.
A. process
B. Thread
C. Servlet
D. GenericServlet
Answer optionc
Marks: 1
679 GenericServlet class implements _____ and __________ interfaces.
A. ServletRequest and ServletResponse
B. ServletResponse and Servlet
C. Servlet and ServletConfig
D. None of these
Answer optionc
Marks: 2
680 ________class provides stream to read binary data from the request.
A. ServletException
B. GenericServlet
C. ServletOutputStream
D. ServletInputStream
Answer optiond
Marks: 1
681 ________ class indicates that a servlet error occurred.
A. ServletException
B. IOExeption
C. ServletNotFound
D. None of these
Answer optiona
Marks: 1
682 ___________ indicates that a servlet is permanently or temporarily u
A. ServletUnavailableException
B. IllegalException
C. ServletException
D. UnavailableException
Answer optiond
Marks: 1
683 The default alignment of buttons in Flow Layout is ..........
A. LEFT
B. CENTER
C. RIGHT
D. JUSTIFY
Answer optionb
Marks: 1
684 The default horizontal and vertical gap in FlowLayout is
A. 0 Pixel
B. 1 Pixel
C. 5 Pixel
D. 10 Pixel
Answer optionc
Marks: 1
685 The default horizontal and vertical gap in BorderLayout is
A. 0 Pixel
B. 1 Pixel
C. 5 Pixels
D. 10 Pixels
Answer optiona
Marks: 1
686 Which of the following interface allows a servlet to get initializatio
A. ServletConfig
B. ServletContext
C. ServletRequest
D. ServletResponse
Answer optiona
Marks: 1
687 getServletContext() returns the __________ for this servlet.
A. value
B. context
C. enumeration
D. None of these
Answer optionb
Marks: 1
Which of the following method returns the value of the initialization
688 param
A. ServletContextgetServletContext()
B. String getInitParameter(String param)
C. Enumeration getInitParameterNames()
D. String getServerInfo()
Answer optionb
Marks: 1
689 The ServletContext interface is implemented by the ________
A. client
B. server
C. cookie
D. session
Answer optionb
Marks: 1
Which of the following interface enables the servlet to obtain informa
690 environment?
A. ServletContext
B. ServletConfig
C. ServletRequest
D. ServletResponse
Answer optiona
Marks: 1
___________ methods are dangerous to use because they can corrupt the
691 machine.
A. getServlet()
B. getServletNames()
C. both a and b
D. None of these
Answer optionc
Marks: 1
692 ________returns the port number to which the request was sent.
A. String getScheme()
B. String getServerName()
C. int getServerPort()
D. String getRemoteHost()
Answer optionc
Marks: 1
693 . ________ returns the host name of the server to which the request wa
A. String getScheme()
B. String getServerName()
C. int getServerPort()
D. String getRemoteHost()
Answer optionb
Marks: 1
______ method returns the name of the scheme used to make this reques
694 http, https, or ftp.
A. getScheme()
B. setScheme()
C. putScheme()
D. none of the above
Answer optiona
Marks: 1
________ Returns the fully qualified name of the client or the last
695 the request.
A. String getRemoteHost()
B. String getRemoteAddr()
C. String getProtocol()
D. None of these
Answer optiona
Marks: 1
Which of the following package is missing for the below program?
import java.io.*:
import javax.servlet.*;
public class PostParameterServlet extends GenericServlet{
696 public void service(ServletRequest request, ServletResponse response
throws ServletException ,IOException{
Printwriter pw= response.getWriter();
Enumeration e= request.getParameterNames();
while(e.hasMoreElements()) {
String pname= (String) e.nextElement();
pw.print(pname + "= ");
Sting pvalue = request.getParameter(pname);
pw.println(pvalue);
}
pw.close();
}
}
A. import.java.util.*;
B. import javax.servlet.http.*;
C. import java.awt.*;
D. None of these
Answer optiona
Marks: 2
Write the missing statement in the below code
import javax.servlet.*;
public class WelcomeServlet extends GenericServlet
{
public void service( ServletRequest request,ServlerResponse response)
697 ServletException ,IOException
{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<b> Hello");
}
}
A. pw.close()
B. pw.stop()
C. pw.destroy()
D. none of these
Answer optiona
Marks: 2
Identify the missing statement at line no. 6.
1. import java.io.*;
2. import javax.servlet.*;
3. public class First extends GenericServlet{
4. public void service(ServletRequest req,ServletResponse res) thr
ServletException{
698 5. res.setContentType("text/html");
6. ?
7. out.print("<html><body>");
8. out.print("<b>hello generic servlet</b>");
9. out.print("</body></html>");
10. }
11. }
A. PrintWriter out=res.getWriter();
B. PrintWriter in = res.getWriter()
C. PrintWriter out=res.putWriter();
D. PrintWriter in = res.putWriter()
Answer optiona
Marks: 2
699 Which method is used to specify before any lines that uses the PrintWr
A. SetPageType()
B. SetType()
C. setContextType()
D. setResponseType()
Answer optionc
Marks: 1
700 Which method of servlet is/are called several times in its life?
A. destroy()
B. service()
C. init()
D. none of above
Answer optiond
Marks: 1
In a web application, running in a web server, servlet is responsibl
701 creating______object.
A. request and response
B. request only
C. response only
D. none of above
Answer optiona
Marks: 1
702 Servlets execute ______of a web server
A. within the address space
B. out of the address space
C. any address space
D. none of the above
Answer optiona
Marks: 1
703 The UnavailableException Class is subclass of ______
A. IllegalArgumentException
B. ClassNotFoundExceptin
C. ServletException
D. All Of The Above
Answer optionc
Marks: 1
704 Which of the following method Write s and stack the trace for e to th
A. void log(Throwable e )
B. void log( String s)
C. void log()
D. void log(String s, Throwable e)
Answer optiond
Marks: 1
Which of the following method returns an enumeration with the name of
705 same namespace in the server?
A. String getInitParameter(String param)
B. Enumeration getInitParameterNames()
C. Enumeration getServletNames()
D. None of these
Answer optionc
Marks: 1
706 _____________ returns the real path that corresponds to the virtua
A. String getServerInfo()
B. String getMimeType(String File)
C. String getRealPath(String vpath)
D. int getContentLength()
Answer optionc
Marks: 1
The ________ interface is used to indicate that only a single threa
707 the service() method of a servlet.
A. SingleThreadModel
B. UnithreadModel
C. ThreadModel
D. None of These
Answer optiona
Marks: 1
708 The SingleThreadModel interface defines no constants and declares no
A. True
B. False
C.
D.
Answer optiona
Marks: 1
The servlet programmer should implement_______ interface to ensure tha
709 handle only one request at a time.
A. ServletResponse
B. ServlerRequest
C. SingleThreadModel
D. None of these
Answer optionc
Marks: 1
Which of the following class provides implementations of the basic l
710 for a servlet.
A. Servlet InputStream
B. GenericServlet
C. ServletException
D. Servlet OutputStream
Answer optionb
Marks: 1
711 void log(String s) method belongs to which of the following classes.
A. GenericServlet Class
B. Servlet OutputStream Class
C. Servlet InputStream Class
D. None of These
Answer optiona
Marks: 1
Every servlet has it's own ________object and servlet container is res
712 instantiating this object.
A. ServletConfig
B. servletContext
C. Both A and B
D. none of the above
Answer optiona
Marks: 1
The ServletContext is _______ object and available to all the servlets
713 application.
A. unique
B. seperate
C. different
D. optional
Answer optiona
Marks: 1
714 Which of the following is the unique object per servlet?
A. ServletConfig
B. ServletContext
C. ServletRequest
D. None of these
Answer optiona
Marks: 1
715 . _______ is an unique object for complete application.
A. ServletConfig
B. ServletContext
C. ServletRequest
D. None of these
Answer optionb
Marks: 1
We cannot set attributes in ________ interface that other servlets can
716 implementations.
A. ServletConfig
B. ServletContext
C. ServletRequest
D. None of these
Answer optionb
Marks: 1
717 ______interface is used for inter-servlet communication
A. RequestDispatcher
B. ServlerRequest
C. ServletResponse
D. none of above
Answer optiona
Marks: 1
Which of the following interface is used to forward the request to a
718 that can be HTML, JSP or another servlet in same application?
A. Request Dispatcher Interface
B. SinglethreadModel Interface
C. ServletResponse Interface
D. None of These
Answer optiona
Marks: 1
Which of the following method forwards the request from a servlet to
719 (servlet, JSP file, or HTML file) on the server?
A. void include(ServletRequest request, ServletResponse response)
B. void forward(ServletRequest request, ServletResponse response)
C. void include(ServletRequest request)
D. void forward(ServletRequest request)
Answer optionb
Marks: 1
720 ________ is protocol independent implementation of Servlet
A. ServletInputStream
B. ServletOutputStream
C. GenericServlet
D. None of These
Answer optionc
Marks: 1
Which of the following interface guarantees that no two threads will e
721 in the servlet's service method ?
A. ServletResponse
B. ServletRequest
C. SingleThreadModel
D. ServletConfig
Answer optionc
Marks: 1
722 ______ is the super class of all servlets.
A. GenericServlet
B. HttpServlet
C. Servlet
D. none of above
Answer optiona
Marks: 1
723 How many ServletContext objects are available for an entire web applic
A. One each per servlet
B. One each per request
C. One each per response
D. Only one
Answer optiond
Marks: 1
724 Servlet creates ______ thread for each request of client.
A. single
B. two
C. multiple
D. None of These
Answer optiona
Marks: 1
725 Servlet runs each request in a __________ ?
A. OS shell
B. JVM
C. Separate thread
D. JRE
Answer optionc
Marks: 1
726 GenericServlet class is encapsulated inside __________ package
A. java.lang
B. javax.servlet
C. java.servlet
D. javax.servlet.http
Answer optionb
Marks: 1
727 _________ is responsible for managing execution of servlet
A. Web Container
B. Servlet Context
C. JVM
D. Server
Answer optiona
Marks: 1
Consider the following program which class should be extended?
import java.io.*;
import javax.servlet.*;
public class First extends ************{
public void service(ServletRequest req,ServletResponse res)
throws IOException,ServletException{
728 res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.print("<html><body>");
out.print("<b>hello generic servlet</b>");
out.print("</body></html>");
}
}
A. HttpServlet
B. GenericServlet
C. Servlet
D. None of These
Answer optionb
Marks: 2
ItemEvent constructor-
729 ItemEvent(ItemSelectable src, int type, Object entry, int state)
Here entry means......
A. The specific item that generated the item event is passed
B. The type of object
C. a reference to the component that generated event
D. The current state of that item.
Answer optiona
Marks: 1
730 The getItem( ) method can be used...
A. to obtain a reference to the all item
B. to obtain a reference to the item that changed.
C. get reference to the component.
D. get reference to the frame
Answer optionb
Marks: 1
731 The example of user interface elements that implement the ItemSelectab
A. Choices and TextBox
B. TextBox and Lists
C. Lists and choices
D. Lists and canvas
Answer optionc
Marks: 1
732 The getStateChange ( ) method returns the state change.
A. The mouse pressed or released
B. Selected or Deselected
C. A page-up or page-down
D. The window gained input focus.
Answer optionb
Marks: 1
. Debug the following program
import java.awt.*;
import javax.swing.*;
/*
<applet code="JTableDemo" width=400 height=200>
</applet>
*/
public class JTableDemo extends JApplet
{
public void init() {
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
final String[] colHeads = { "emp_Name", "emp_id", "emp_salary" };
733 final Object[][] data = {
{ "Ramesh", "111", "50000" },
{ "Sagar", "222", "52000" },
{ "Virag", "333", "40000" },
{ "Amit", "444", "62000" },
{ "Anil", "555", "60000" },
};
JTable table = new JTable(data);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(table, v, h);
contentPane.add(jsp, BorderLayout.CENTER);
}
}
A. Error in statement in which applet tag is declared
B. Error in statement in which JScrollPane is created
C. Error in statement in which JTable is created
D. None of the above
Answer optionc
Marks: 2
Cookie ck=new Cookie("auth",null);
ck.setMaxAge(0);
734
A _______ value in the above method means that the cookie is not store
will be deleted when the Web browser exits.
A. Negative, Positive
B. Positive
C. Zero
D. Negative
Answer optiond
Marks: 1
A cookie's value can uniquely identify a client, so cookies are common
735 ___________________.
A. Cookie Management
B. Session Management
C. Http Management
D. Servlet
Answer optionb
Marks: 1
736 ________ is removed each time when user closes the browser.
A. Non-persistent cookie
B. Persistent cookie
C. session
D. httpservlet
Answer optiona
Marks: 1
737 __________________ valid for single session only.
A. Persistent cookie
B. Non-persistent cookie
C. session
D. httpservlet
Answer optionb
Marks: 1
___________ is not removed each time when user closes the browser. It
738 user logout or sign out.
A. Non-persistent cookie
B. Persistent cookie
C. session
D. httpservlet
Answer optionb
Marks: 1
739 _____________ is valid for multiple session
A. Persistent cookie
B. Non-persistent cookie
C. session
D. httpservlet
Answer optiona
Marks: 1
Chose the correct output following code
740 import javax.swing.*;
class TextFieldExample
{
public static void main(String args[])
{
JFrame f= new JFrame("TextField Example");
JTextField t1,t2;
t1=new JTextField("Welcome to Javatpoint.");
t1.setBounds(50,100, 200,30);
t2=new JTextField("AWT Tutorial");
t2.setBounds(50,150, 200,30);
f.add(t1); f.add(t2);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
}
}
A.
B.
C.
D.
Answer optionb
Marks: 2
741 Identify the methods which belong to Cookies.
A. public void setMaxAge(int expiry)
B. public String getName()
C. public String getValue()
D. All of above
Answer optiond
Marks: 1
742 Which of the following methods are related to Cookies?
A. public void setName(String name)
B. public void setValue(String value)
C. public Cookie[] getCookies()
D. All of above
Answer optiond
Marks: 1
Find which of the following options contains error :
import java.applet.*;
import java.awt.*;
import javax.swing.*;
Public class fonts extends JApplet
{
Public void paint(Graphics g)
743 {
String str =" ";
String FontList[];
GraphicsEnvironment ge= GraphicsEnvironment.getLocalGraphicsEnvironmen
FontList=ge.getAvailableFontFamilyNames();
For(int i=0;i<fontlist.length;i++)
Str+=FontList[i]+ " ";
g.drawString(str,10,16);
}
}
A. str+=FontList[i]+ "";
B. String FontList[];
C. For(int i=0;i<fontlist.length;i++)
D. none of the above
Answer optionc
Marks: 2
Choose the correct output to display the following Code.
import javax.swing.*;
import java.awt.event.*;
public class TextFieldExample implements ActionListener{
JTextField tf1,tf2,tf3;
JButton b1,b2;
TextFieldExample(){
JFrame f= new JFrame();
tf1=new JTextField();
tf1.setBounds(50,50,150,20);
tf2=new JTextField();
tf2.setBounds(50,100,150,20);
tf3=new JTextField();
tf3.setBounds(50,150,150,20);
tf3.setEditable(false);
b1=new JButton("+");
744 b1.setBounds(50,200,50,50);
b2=new JButton("-");
b2.setBounds(120,200,50,50);
b1.addActionListener(this);
b2.addActionListener(this);
f.add(tf1);f.add(tf2);f.add(tf3);f.add(b1);f.add(b2);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
String s1=tf1.getText();
String s2=tf2.getText();
int a=Integer.parseInt(s1);
int b=Integer.parseInt(s2);
int c=0;
if(e.getSource()==b1){
c=a+b;
}else if(e.getSource()==b2){
c=a-b;
}
String result=String.valueOf(c);
tf3.setText(result);
}
public static void main(String[] args) {
new TextFieldExample();
} }
A.
B.
C.
D.
Answer optiona
Marks: 2
import java.net.*;
745 In above statement net is -------
A. package
B. class
C. interface
D. method
Answer optiona
Marks: 1
746 Identify the correct sequence of creating cookies.
1) Create a Cookie object. 2) Set the maximum Age. 3) Place the Cookie
A. header.
1) Set the maximum Age. 2) Place the Cookie in HTTP response header. 3
B. object.
1) Place the cookie in HTTP response header. 2) Set the maximum Age.
C. object."
1) Set the maximum Age. 2) Create a Cookie object. 3)Place the Cookie
D. header.
Answer optiona
Marks: 1
Choose the correct output to display the following code
import javax.swing.*;
public class TextAreaExample
{
TextAreaExample(){
JFrame f= new JFrame();
JTextArea area=new JTextArea("Welcome to javatpoint");
area.setBounds(10,30, 200,200);
747 f.add(area);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String args[])
{
new TextAreaExample();
}}
A. Output
B. Output
C. Output
D. None of the above
Answer optiona
Marks: 2
748 ------ is a protocol
A. netnews
B. Sting
C. hit
D. none of above
Answer optiona
Marks: 1
749 -------is protocol
A. netnews
B. finger
C. e-mail
D. all of the above
Answer optiond
Marks: 1
________________ interface enables a servlet to
750 obtain information about a client request.
A. HttpServletRequest
B. HttpServletResponse
C. httpservletrequest
D. Http Request
Answer optiona
Marks: 1
751 which of the following are the methods in belong to HttpServletReques
A. String getAuthType( )
B. Cookie[ ] getCookies( )
C. Both A and B
D. Neither A nor B
Answer optionc
Marks: 1
752 choose the output for following code:
package jprogressbardemo;
import java.awt.*;
import javax.swing.*;
public class Main {
public static void main(String[] args) {
final int MAX = 100;
final JFrame frame = new JFrame("JProgress Demo");
// creates progress bar
final JProgressBar pb = new JProgressBar();
pb.setMinimum(0);
pb.setMaximum(MAX);
pb.setStringPainted(true);
// add progress bar
frame.setLayout(new FlowLayout());
frame.getContentPane().add(pb);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 200);
frame.setVisible(true);
// update progressbar
for (int i = 0; i <= MAX; i++) {
final int currentValue = i;
try {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
pb.setValue(currentValue);
}
});
java.lang.Thread.sleep(100);
} catch (InterruptedException e) {
JOptionPane.showMessageDialog(frame, e.getMessage());
}
}
}
}
A.
B.
C. both a & b
D. none of the above
Answer optiona
Marks: 2
753 Which of the following methods belong to HttpServletResponse interfa
A. void sendRedirect(String url) throws IOException
B. void sendError(int c, String s) throws IOException
C. Both A and B
D. Neither A nor B
Answer optionc
Marks: 1
754 Which of the following methods belong to in HttpSession interface.
A. String getId( )
B. void invalidate( )
C. long getLastAccessedTime( )
D. All of the above
Answer optiond
Marks: 1
755 What components will be needed to get following output?
A. JLabel, JTabbedPane, JCheckBox
B. JTabbedPane, JList, JApplet
C. JPanel, JTabbedPane, JList
D. JApplet, JTabbedPane, JPanel
Answer optionc
Marks: 2
_______________enables a servlet to read and write the state informati
756 associated with an HTTP session.
A. HttpRequest
B. HttpSession
C. HttpServletRequest
D. HttpServletResponse
Answer optionb
Marks: 1
Choose the correct output to display the following Code.
import javax.swing.*;
757 import java.awt.event.*;
public class TextAreaExample implements ActionListener{
JLabel l1,l2;
JTextArea area;
JButton b;
TextAreaExample() {
JFrame f= new JFrame();
l1=new JLabel();
l1.setBounds(50,25,100,30);
l2=new JLabel();
l2.setBounds(160,25,100,30);
area=new JTextArea();
area.setBounds(20,75,250,200);
b=new JButton("Count Words");
b.setBounds(100,300,120,30);
b.addActionListener(this);
f.add(l1);f.add(l2);f.add(area);f.add(b);
f.setSize(450,450);
f.setLayout(null);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e){
String text=area.getText();
String words[]=text.split(" ");
l1.setText("Words: "+words.length);
l2.setText("Characters: "+text.length());
}
public static void main(String[] args) {
new TextAreaExample();
}
}
A.
B.
C. Both A & B
D. None of the above
Answer optionb
Marks: 2
Choose the correct output to display the following code.
import javax.swing.*;
public class PasswordFieldExample {
public static void main(String[] args) {
JFrame f=new JFrame("Password Field Example");
JPasswordField value = new JPasswordField();
JLabel l1=new JLabel("Password:");
758 l1.setBounds(20,100, 80,30);
value.setBounds(100,100,100,30);
f.add(value); f.add(l1);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
}
A.
B.
C.
D.
Answer optiona
Marks: 2
choose the correct output for for following code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/*
<applet code="JComboBoxDemo" width=300 height=100>
</applet>
759 */
public class JComboBoxDemo extends JApplet
implements ItemListener {
JLabel jl;
ImageIcon france, germany, italy, japan;
public void init() {
// Get content pane
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
// Create a combo box and add it
// to the panel
JComboBox jc = new JComboBox();
jc.addItem("France");
jc.addItem("Germany");
jc.addItem("Italy");
jc.addItem("Japan");
jc.addItemListener(this);
contentPane.add(jc);
// Create label
jl = new JLabel(new ImageIcon("france.gif"));
contentPane.add(jl);
}
public void itemStateChanged(ItemEvent ie) {
String s = (String)ie.getItem();
jl.setIcon(new ImageIcon(s + ".gif"));
}
}
A.
B.
C.
D. none of the above
Answer optiona
Marks: 2
import java.net.ServerSocket;
760 In above statement ServerSocket is -----------
A. package
B. class
C. interface
D. method
Answer optionb
Marks: 1
choose output for following code:
import javax.swing.*;
import java.lang.*;
public class ToolTipExample {
public static void main(String[] args) {
//Creating PasswordField and label
JPasswordField value = new JPasswordField();
761 value.setBounds(100,100,100,30);
value.setToolTipText("Enter your Password");
JLabel l1=new JLabel("Password:");
l1.setBounds(20,100, 80,30);
//Adding components to frame
f.add(value); f.add(l1);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
}
A. Error in the program
B.
C.
D. none of the above
Answer optiona
Marks: 2
Find the missing statement from the following code:
import javax.swing.*;
import java.lang.*;
public class ToolTipExample {
public static void main(String[] args) {
_________________________________
//Creating PasswordField and label
JPasswordField value = new JPasswordField();
762 value.setBounds(100,100,100,30);
value.setToolTipText("Enter your Password");
JLabel l1=new JLabel("Password:");
l1.setBounds(20,100, 80,30);
//Adding components to frame
f.add(value); f.add(l1);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
}
A. JPanel p=new JPanel("Password Field Example");
B. JFrame f=new JFrame("Password Field Example");
C. JContentPane c=new JContentPane("Password Field Example");
D. none of the above
Answer optionb
Marks: 2
763 Which of these is a full form of DNS?
A. Data Network Service
B. Data Name Service
C. Domain Network Service
D. Domain Name Service
Answer optiond
Marks: 1
764 The HttpSession interface is implemented by the __________.
A. session
B. cookies
C. client
D. server
Answer optiond
Marks: 1
765 A cookie is stored on a _______ and contains state information.
A. Session
B. Cookies
C. client
D. server
Answer optionc
Marks: 1
766 UDP support -------
A. a simpler communication
B. a faster communication
C. point to point data gram oriental model
D. All of the above
Answer optiond
Marks: 1
Panel is a pure container and is not a window in itself. The sole purp
767 to organize the components on to a window.
A. True
B. False
C.
D.
Answer optiona
Marks: 1
768 Swing is a ----------------------------, whose components are all ulti
the javax.swing.JComponent class.
A. Model-Based
B. component-based framework
C. Relational Based
D. None of the above
Answer optionb
Marks: 1
769 java.net package's interfaces are____________
A. URLConnection
B. ContentHandlerFactory
C. DatagramSocket
D. All of the above
Answer optionb
Marks: 1
Choose correct output for following code:
import javax.swing.*;
import java.awt.event.*;
770 public class PasswordFieldExample {
public static void main(String[] args) {
JFrame f=new JFrame("Password Field Example");
final JLabel label = new JLabel();
label.setBounds(20,150, 200,50);
final JPasswordField value = new JPasswordField();
value.setBounds(100,75,100,30);
JLabel l1=new JLabel("Username:");
l1.setBounds(20,20, 80,30);
JLabel l2=new JLabel("Password:");
l2.setBounds(20,75, 80,30);
JButton b = new JButton("Login");
b.setBounds(100,120, 80,30);
final JTextField text = new JTextField();
text.setBounds(100,20, 100,30);
f.add(value);
f.add(l1);
f.add(label);
f.add(l2);
f.add(b);
f.add(text);
}
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String data = "Username " + text.getText();
data += ", Password: "+ new String(value.getPassword());
label.setText(data);
}
});
}
}
A. Error in the program
B.
C.
D.
Answer optiona
Marks: 2
771 Constructor of JCheckBoxMenuItem is
A. JCheckBoxMenuItem()
B. JCheckBoxMenuItem(Action a)
C. JCheckBoxMenuItem(String text, boolean b)
D. All of the above
Answer optiond
Marks: 1
772 Constructor of JTable is
A. JTable()
B. JTable(Object[][] rows, Object[] columns)
C. Both A & B
D. None of the above
Answer optionc
Marks: 1
Choose correct output for following code:
import javax.swing.*;
773 class MenuExample
{
JMenu menu, submenu;
JMenuItem i1, i2, i3, i4, i5;
MenuExample(){
JFrame f= new JFrame("Menu and MenuItem Example");
JMenuBar mb=new JMenuBar();
menu=new JMenu("Menu");
submenu=new JMenu("Sub Menu");
i1=new JMenuItem("Item 1");
i2=new JMenuItem("Item 2");
i3=new JMenuItem("Item 3");
i4=new JMenuItem("Item 4");
i5=new JMenuItem("Item 5");
menu.add(i1); menu.add(i2); menu.add(i3);
submenu.add(i4); submenu.add(i5);
menu.add(submenu);
mb.add(menu);
f.setJMenuBar(mb);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String args[])
{
new MenuExample();
}}
A.
B.
C.
D.
Answer optiond
Marks: 2
774 Select Correct Code for Given Output:
import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode
A. TreeExample { TreeExample(){ f=new JFrame(); DefaultMu
style=new DefaultMutableTreeNode("Style"); DefaultMutableTreeNod
DefaultMutableTreeNode("color"); DefaultMutableTreeNode font=new
DefaultMutableTreeNode("font"); style.add(color); style.ad
DefaultMutableTreeNode red=new DefaultMutableTreeNode("red");
DefaultMutableTreeNode blue=new DefaultMutableTreeNode("blue");
DefaultMutableTreeNode black=new DefaultMutableTreeNode("black");
DefaultMutableTreeNode green=new DefaultMutableTreeNode("green");
color.add(blue); color.add(black); color.add(green); JTree j
f.add(jt); f.setSize(200,200); f.setVisible(true); } p
main(String[] args) { new TreeExample(); }}
import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode
TreeExample { JFrame f; TreeExample(){ f=new JFrame();
DefaultMutableTreeNode style=new DefaultMutableTreeNode("Style");
DefaultMutableTreeNode color=new DefaultMutableTreeNode("color");
DefaultMutableTreeNode font=new DefaultMutableTreeNode("font");
style.add(font); DefaultMutableTreeNode red=new DefaultMutableTr
B. DefaultMutableTreeNode blue=new DefaultMutableTreeNode("blue");
DefaultMutableTreeNode black=new DefaultMutableTreeNode("black");
DefaultMutableTreeNode green=new DefaultMutableTreeNode("green");
color.add(blue); color.add(black); color.add(green); JTree j
f.add(jt); f.setSize(200,200); f.setVisible(true); } p
main(String[] args) { new TreeExample(); }}
import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode
TreeExample { JFrame f; TreeExample(){ f=new JFrame();
DefaultMutableTreeNode style=new DefaultMutableTreeNode("Style");
DefaultMutableTreeNode color=new DefaultMutableTreeNode("color");
DefaultMutableTreeNode font=new DefaultMutableTreeNode("font");
style.add(font); DefaultMutableTreeNode red=new DefaultMutableTr
C. DefaultMutableTreeNode blue=new DefaultMutableTreeNode("blue");
DefaultMutableTreeNode black=new DefaultMutableTreeNode("black");
DefaultMutableTreeNode green=new DefaultMutableTreeNode("green");
color.add(blue); color.add(black); color.add(green); f.
f.setSize(200,200); f.setVisible(true); } public static void
args) { new TreeExample(); }}
import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode
TreeExample { JFrame f; TreeExample(){ f=new JFrame();
DefaultMutableTreeNode style=new DefaultMutableTreeNode("Style");
DefaultMutableTreeNode color=new DefaultMutableTreeNode("color");
D. DefaultMutableTreeNode font=new DefaultMutableTreeNode("font");
style.add(font); DefaultMutableTreeNode red=new DefaultMutableTr
DefaultMutableTreeNode blue=new DefaultMutableTreeNode("blue");
DefaultMutableTreeNode black=new DefaultMutableTreeNode("black");
DefaultMutableTreeNode green=new DefaultMutableTreeNode("green");
color.add(blue); color.add(black); color.add(green); JTree j
} public static void main(String[] args) { new TreeExample();
Answer optionb
Marks: 2
Choose correct output for following code:
import javax.swing.*;
public class RadioButtonExample {
JFrame f;
RadioButtonExample(){
f=new JFrame();
JRadioButton r1=new JRadioButton("A) Male");
JRadioButton r2=new JRadioButton("B) Female");
r1.setBounds(75,50,100,30);
775 r2.setBounds(75,100,100,30);
ButtonGroup bg=new ButtonGroup();
bg.add(r1);bg.add(r2);
f.add(r1);f.add(r2);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String[] args) {
new RadioButtonExample();
}}
A.
B.
C.
D. all the above
Answer optiona
Marks: 2
776 What is the difference between scrollbar and scrollpane
A Scrollpane is a Component, but not a Container whereas Scrollbar is
A. handles its own events and perform its own scrolling.
A Scrollbar is a Component, but not a Container whereas Scrollpane is
B. handles its own events and perform its own scrolling
A Scrollbar is handles not its own events and perform its own scrolli
C. Scrollpane handles not its own events and perform its own scrolling
D. all the above
Answer optionb
Marks: 1
777 What does x mean in javax.swing
A. x mean in javax.swing is Extension of java
B. x mean in javax.swing is Extreme of java
C. x mean in javax.swing is Ex. of java
D. x mean in javax.swing is Extra of java
Answer optiona
Marks: 1
778 A layout manager is basically an object, Its mainly used to organize
A. components in a container
B. Objects in a container
C. components in a window
D. Objects in a panel
Answer optiona
Marks: 1
Find missing statement to get the output shown
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class LabelExample extends Frame implements ActionListener{
JTextField tf; JLabel l; JButton b;
LabelExample(){
tf=new JTextField();
tf.setBounds(50,50, 150,20);
l=new JLabel();
l.setBounds(50,100, 250,20);
b=new JButton("Find IP");
b.setBounds(50,150,95,30);
b.addActionListener(this);
779 add(b);add(tf);add(l);
setSize(400,400);
setLayout(null);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
try{
String host=tf.getText();
____________________________________________
l.setText("IP of "+host+" is: "+ip);
}catch(Exception ex){System.out.println(ex);}
}
public static void main(String[] args) {
new LabelExample();
} }
A. String ip=java.net.InetAddress.getHostAddress();
B. String ip=java.net.InetAddress.getByName(host).getHostAddress();
C. String ip=java.net.InetAddress.getByName(host);
D. None of the above
Answer optionb
Marks: 2
Choose correct output for following code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DialogExample {
private static JDialog d;
DialogExample() {
JFrame f= new JFrame();
d = new JDialog(f , "Dialog Example", true);
d.setLayout( new FlowLayout() );
JButton b = new JButton ("OK");
b.addActionListener ( new ActionListener()
{
public void actionPerformed( ActionEvent e )
780 {
DialogExample.d.setVisible(false);
}
});
d.add( new JLabel ("Click button to continue."));
d.add(b);
d.setSize(300,300);
d.setVisible(true);
}
public static void main(String args[])
{
new DialogExample();
}
}
A.
B.
C.
D. none of the above
Answer optionc
Marks: 2
781 TreeNode and MutableTreeNode is___________
A. Both are classes
B. class and interface
C. Both are interfaces
D. interface and class
Answer optionc
Marks: 1
Find Correct Output for given Code :
import javax.swing.*;
public class ToolTipExample {
public static void main(String[] args) {
782 JFrame f=new JFrame("Password Field Example");
JPasswordField value = new JPasswordField();
value.setBounds(100,100,100,30);
value.setToolTipText("Enter your Password");
JLabel l1=new JLabel("Password:");
l1.setBounds(20,100, 80,30);
f.add(value); f.add(l1);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true); } }
A. Error
B.
C.
D.
Answer optionb
Marks: 2
783 Which method is used to change size and position of Components?
A. void set(int x,int y,int width,int height)
B. void setBounds(int width,int height,int x)
C. void setbounds(int x,int y,int width,int height)
D. void setBounds(int x,int y,int width,int height)
Answer optiond
Marks: 1
784 JRadioButton is a subclass of ________ class.
A. AbstractButton
B. ButtonGroup
C. JButton
D. ImageIcon
Answer optiona
Marks: 1
785 To implement swings which package is to be imported from the following
A. javax.JSwing
B. java.swing
C. java.javax
D. javax.swing
Answer optiond
Marks: 1
import java.awt.*;
import java.applet.*;
public class ListExapp extends Applet
/* <applet code="ListExapp" width=300 height=300></applet>*/
{
public void init()
786 {
List c=new List(6);
c.add("C");
c.add("C++");
c.add("Java");
c.add("PHP");
c.add("Android");
add(c);
}
} What is the ouput of above code ?
A.
B.
C.
D.
Answer optiona
Marks: 2
787 The default layout manager for the content pane of a swing based apple
A. GridBoxLayout
B. CardLayout
C. FlowLayout
D. Border-Layout
Answer optionc
Marks: 1
Which of the following GridBagLayout variable defines the external pad
788 around the component in its display area?
A. gridwidth, gridheight
B. gridx, gridy
C. ipadx, ipady
D. insets
Answer optiond
Marks: 1
Which of the following GridBagLayout variables defines the padding tha
789 each side of the component?
A. gridwidth, gridheight
B. gridx, gridy
C. ipadx, ipady
D. insets
Answer optionc
Marks: 1
Which of the following GridBagLayout variables specifies the number of
790 the component horizontally and vertically in the grid?
A. gridwidth, gridheight
B. gridx, gridy
C. ipadx, ipady
D. insets
Answer optiona
Marks: 1
Which component displays information in hierarchical manner with paren
791 relationship?
A. AWT
B. Frame
C. Swing
D. Window
Answer optionc
Marks: 1
792 What is the name of the Swing class that is used for frames?
A. SwingFrame
B. Window
C. Frame
D. JFrame
Answer optiond
Marks: 1
Swing is the set of ____________ that provides more powerful & flexibl
793 compare to Abstract Window Tooklit (AWT).
A. constructors
B. methods
C. classes
D. destructors
Answer optionc
Marks: 1
794 Which method is used to close a swing frame
A. WINDOW_CLOSING
B. WindowEvent(Window src, int type, Window other)
C. windowClosing(WindowEvent we)
D. setDefaultCloseOperation()
Answer optiond
Marks: 1
795 Select the correct code for following output
A. import java.awt.*; import java.applet.*; public class ListExapp exte
<applet code="ListExapp" width=300 height=300></applet>*/ { publ
c2=new Checkbox("Server Side"); List c=new List(5); c.
c.add("C++"); c.add("Java"); c.add("PHP");
c.add("Android"); add(c1); add(c2);
import java.awt.*; import java.applet.*; public class ListExapp exte
<applet code="ListExapp" width=300 height=300></applet>*/ { publ
c2=new Checkbox("Server Side"); List c=new List(5); c.
B. c.add("C++"); c.add("Java"); c.add("PHP");
c.add("Android"); add(c1); add(c2); add(
add(b2); } }
import java.awt.*; import java.applet.*; public class ListExapp exte
<applet code="ListExapp" width=300 height=300></applet>*/ { publ
c2=new Checkbox("Server Side"); List c=new List(5); c.
C. c.add("C++"); c.add("Java"); c.add("PHP");
c.add("Android"); add(c1); add(c);
add(b2); } }
import java.awt.*; import java.applet.*; public class ListExapp exte
<applet code="ListExapp" width=300 height=300></applet>*/ { publ
D. c2=new Checkbox("Server Side"); List c=new List(5); c.
c.add("C++"); c.add("Java"); c.add("PHP");
c.add("Android"); add(c1); add(c2);
Answer optiond
Marks: 2
796 Which of the following is not a swing class?
A. JComboBox
B. JFrame
C. JComponent
D. canvas
Answer optiond
Marks: 1
797 __________ is a Swing class that allows the user to enter a multipleli
A. JLabel
B. JTextField
C. JTextArea
D. JComboBox
Answer optionc
Marks: 1
798 _____________________ is not a Swing Component
A. CheckboxGroup
B. CheckBox
C. JComboBox
D. all the above
Answer optiona
Marks: 1
799 which AWT components are added in given output ?
A. Button,TextField
B. Label,TextField
C. Button,Label ,TextArea
D. TextField,Button,TextArea
Answer optionc
Marks: 1
800 The Jtable of swings is used to display data in form of_____________
A. JTable object displays rows and columns of data.
B. JTable object displays rows ONLY.
C. JTable object displays columns ONLY
D. none of the above
Answer optiona
Marks: 1
801 Which of the following view file types are supported in MVC?
A. .cshtml
B. .vbhtml
C. .aspx
D. All of the above
Answer optiond
Marks: 1
Observe the following code
import java.awt.*;
import java.applet.*;
public class LayoutDemo5 extends Applet
{
public void init()
{
int i,j,k,n=4;
setLayout(new BorderLayout());
Panel p1=new Panel();
Panel p2=new Panel();
p1.setLayout(new FlowLayout());
802 p1.add(new TextField(20));
p1.add(new TextField(20));
p2.setLayout(new GridLayout(5,3));
p2.add(new Button("OK"));
p2.add(new Button("Submit"));
add(p1,BorderLayout.EAST);
add(p2,BorderLayout.WEST);
}
}
/*<applet code=LayoutDemo5.class width=300 height=400>
</applet>*/
What will be the output of the above program?
A. The output is obtained in Frame with two layouts: Frame layout and Flo
B. The output is obtained in Applet with two layouts: Frame layout and Fl
C. The output is obtained in Applet with two layouts: Frame layout and Bo
D. The output is obtained in Applet with two layouts: Border layout and F
Answer optiond
Marks: 2
803 Term in MVC architecture that receives events is called as_________
A. Receiver
B. Controller
C. Transmitter
D. Modulator
Answer optionb
Marks: 1
804 Which is the best approach to assign a session in MVC?
A. System.Web.HttpContext.Current.Session["LoginID"] =7;
B. Current.Session["LoginID"] =7;
C. Session["LoginID"] =7;
D. None
Answer optionb
Marks: 1
805 ___________Constructs a new scroll bar with the specified orientation
A. Scrollbar()
B. Scrollbar(int )
C. Scrollbar(int , int , int , int , int)
D. All of above
Answer optionb
Marks: 1
The class JList is a component which displays _________and allows the
806 or more items.
A. List of lists
B. list of objects
C. MVC Model
D. Item List
Answer optionb
Marks: 1
import java.awt.*;
public class microGUI
{
807 public static void main ( String[] args )
{
Frame frm = new ___________();
frm.___________( 150, 100 );
frm.___________( true );
}
}
Fill in the blanks with correct sequence of methods.
A. Form, setVisible, setOn
B. Frame, setSize, setVisible
C. Frame, setVisible, setSize
D. Window, setSize, paint
Answer optionb
Marks: 2
808 Which is the correct constructor of GridLayout
A. GridLayout(int numrows)
B. GridLayout(int numrows, int numcols,intx)
C. GridLayout(int numrows, int numcols,intx,inty)
D. GridLayout(int numrows, int numcols)
Answer optiond
Marks: 1
class helloFrame ___________ Frame
{
809 public void ___________( Graphics g )
{
g.___________("Hello", 10, 50 );
}
}
public class Tester
{
public static void main ( String[] args )
{
helloFrame frm = new helloFrame();
frm.setSize( 150, 100 );
frm.setVisible( true );
}
}
fill in the blanks with correct option.
A. import, drawString, paint
B. extends, paint, drawString
C. extends, draw, paint
D. include, drawString, paint
Answer optionb
Marks: 2
810 Panel is a concrete subclass of _______________.
A. Window
B. Container.
C. Panel
D. Frame
Answer optionb
Marks: 1
811 From Following list which is not a swing class?
A. ImageIcon
B. JIcon
C. JButton
D. JPane
Answer optionb
Marks: 1
import java.awt.*;
import java.applet.*;
public class buttonDemo extends Applet
/* <applet code="buttonDemo" width=300 height=300></applet>*/
{
public void init()
Button a1=new Button("ok");
812 Button a2=new Button("Cancel");
Button a3=new Button("Submit");
a2.setLabel("Welcome");
a3.setEnabled(false);
add(a1);
add(a2);
add(a3);
}
}
What will be the output ?
A.
B.
C.
D.
Answer optiond
Marks: 2
A ___________________ array of strings is created for specifying the
813 JTable.
A. two-dimensional
B. one-dimensional
C. multi dimensional
D. none of these
Answer optionb
Marks: 1
814 JProgressBar() of swings creates______________
A. Vertical Progress Bar Only
B. Horizontal Progress Bar with Progress String.
C. Horizontal and Vertical Progress Bar without progress string.
D. Horizontal Progress Bar without progress string.
Answer optiond
Marks: 1
815 Which is correct statement from given option for using a table in an
A. Create aJScrollPaneobject
B. Add the table to the scroll pane.
C. Create aJTableobject
D. All of the above
Answer optiond
Marks: 1
816 Java Swings is used to create ______________________ applications.
A. mobile enabled
B. web based
C. window based
D. package based
Answer optionc
Marks: 1
817 To add tab to the panel which method is used?
A. addTab()
B. addJPanel()
C. addPanel()
D. addJTab()
Answer optiona
Marks: 1
818 How to change the current layout managers for a container?
A. ChangeLayout() method
B. isLayout() method
C. setLayout() method
D. getLayout() method
Answer optionc
Marks: 1
819 Select the correct code for given output?
import java.awt.*; import java.applet.*; public class buttonDemo1 ext
<applet code="buttonDemo1" width=300 height=300></applet>*/ {
A. init() { Button a1=new Button("ok");
Button a2=new Button("Cancel"); Button a3=new Button(
add(a1); add(a2); add(a3);
B. import java.awt.*; import java.applet.*; public class buttonDemo1 ext
<applet code="buttonDemo1" width=300 height=300></applet>*/ {
init() { Button a1=new Button("ok");
Button a2=new Button("Cancel"); Button a3=new Button(
a2.setEnabled(false); add(a1); add(a2);
add(a3); } }
import java.awt.*; import java.applet.*; public class buttonDemo1 ext
<applet code="buttonDemo1" width=300 height=300></applet>*/ {
init() { Button a1=new Button("ok");
C. Button a2=new Button("Cancel"); Button a3=new Button(
a2.setEnabled(true); add(a1); add(a2);
add(a3); } }
import java.awt.*; import java.applet.*; public class buttonDemo1 ext
<applet code="buttonDemo1" width=300 height=300></applet>*/ {
init() { Button a1=new Button("ok");
D. Button a2=new Button("Cancel"); Button a3=new Button(
a1.setEnabled(false); add(a1); add(a2);
add(a3); } }
Answer optionb
Marks: 2
820 JComboBox control initially displays _____ entry
A. One
B. Two
C. Empty
D. NULL
Answer optiona
Marks: 1
821 What does the File dialog constructor Dialog(Frame parent,String titl
A. Creates a file dialog window with the specified title ONLY.
B. Creates a file dialog window with the specified title for loading or s
C. Creates a file dialog window with the specified title for loading ONLY
D. Creates a file dialog window with the specified title for saving a fil
Answer optionb
Marks: 1
822 The title of the dialog box is stored in ____________
A. dialog variable
B. Window variable
C. Title variable
D. Frame Variable
Answer optionc
Marks: 1
823 Dialog box is closed then which method is called?
A. Exit()
B. dialog_close()
C. close()
D. dispose()
Answer optiond
Marks: 1
824 AbstractButton is the template class for________________
A. Push Buttons
B. Radio Buttons
C. Check boxes
D. All of the above.
Answer optiond
Marks: 1
825 What is use of 5th parameter in given constructor Scrollbar(int,int,in
A. orientation
B. visible
C. maximum
D. minimum
Answer optionc
Marks: 1
In given constructor what 3rd parameter indicates Scrollbar s=new
826 Scrollbar(0,10,20,0,1000)
A. orientation
B. visible
C. thumbsize
D. none of these
Answer optionc
Marks: 1
827 What is purpose of default constructor of Scrollbar( ) class?
A. To create vertical Scrollbar
B. To create horizontal Scrollbar
C. Both
D. all of above
Answer optiona
Marks: 1
828 The three software parts of a GUI program are:
A. Windows, Buttons, Mice
B. GUI Components, Graphics, Code
C. GUI Components, Event Listeners, Application Code
D. Frames, Code, Events
Answer optionc
Marks: 1
Consider the following code segment. Insert correct code at blank spa
checkbox._____________ (new ItemListener()
{
public void _______________(ItemEvent ie)
{
829 if (checkbox.getState() == true)
{
JOptionPane.showMessageDialog(null, "checkbox is checked");
}
else { JOptionPane.showMessageDialog(null, "checkbox is unch
}
});
A. itemStateChanged, addItem
B. ItemListener, itemChanged
C. StateChanged, addItem
D. addItemListener, itemStateChanged
Answer optiond
Marks: 2
830 Which of the following sets the frame to 300 pixels wide by 200 high?
A. frm.setSize( 300, 200 );
B. frm.setSize( 200, 300 );
C. frm.paint( 300, 200 );
D. frm.setVisible( 300, 200 );
Answer optiona
Marks: 1
831 What is a container object in GUI programming?
A. A container is another name for an array or vector.
B. A container is any class that is made up of other classes.
C. A container is a primitive variable that contains the actual data.
D. A container is an object like a Frame that has other GUI components pl
Answer optiond
Marks: 1
832 Which of the following is the Java toolkit used to write GUI programs
A. GUI toolkit
B. Abstract Windowing Toolkit
C. Graphics Event Toolkit
D. Java Enhancement Toolkit
Answer optionb
Marks: 1
1. import java.awt.*;
2. import java.awt.event.*;
3. public class ItemEx1 implements ItemListener {
4. Frame jf;
5. Checkbox chk1, chk2;
6. Label label1;
7. ItemEx1() {
8. jf= new Frame("Checkbox");
9. chk1 = new Checkbox("Happy");
10. chk2 = new Checkbox("Sad");
11. label1 = new Label();
12. jf.add(chk1);
13. jf.add(chk2);
14. chk1.addItemListener(this);
15. chk2.addItemListener(this);
16. jf.setLayout(new FlowLayout());
17. jf.setSize(220,150);
18. jf.setVisible(true);
833 19. }
20. // Line no 20
21. Checkbox ch =(Checkbox) ie.getItemSelectable();
22. if(ch.getState()==true) {
23. label1.setText(ch.getLabel()+ " is checked");
24. jf.add(label1);
25. jf.setVisible(true);
26 }
27 else {
28 label1.setText(ch.getLabel()+ " is unchecked");
29 jf.add(label1);
30 jf.setVisible(true);
31 }
32 }
33 public static void main(String... ar) {
34 new ItemEx1();
35 }
36 }
Identify correct code at line no 20
A. public void itemModified(ItemEvent ie) {
B. public void itemStateSelectable(ItemEvent ie) {
C. public void itemChange(ItemEvent ie) {
D. public void itemStateChanged(ItemEvent ie) {
Answer optiond
Marks: 2
834 When is the paint() method of a frame object called?
A. The user calls it to display the frame.
B. The main() method calls it once when the program starts.
C. The Java system calls it every time it decides to display the frame.
D. The Java system calls it once when the program starts.
Answer optionc
Marks: 1
1. public void itemStateChanged(ItemEvent ie) {
2. Checkbox ch =(Checkbox)ie.setItemSelectable();
3. if(ch.getState()==true) {
4. label1.setText(ch.getLabel()+ " is checked");
835 5. jf.add(label1);
6. jf.setVisible(true);
7 .}
Which statement is true ?
A. There are syntax errors on line no. 1
B. There are syntax errors on line no. 2
C. There are syntax errors on line no. 4
D. There are syntax errors on line no. 6
Answer optionb
Marks: 2
836 What is a Graphics object?
A. The Graphics object represents the part of the Frame that you can draw
B. The Graphics object represents the whole Frame.
C. The Graphics object represents the entire monitor.
D. The Graphics object represents the graphics board.
Answer optiona
Marks: 1
837 Which of the following determines how the components of a container ar
A. Display Manager
B. Component Manager
C. Stage Manager
D. Layout Manager
Answer optiond
Marks: 1
838 Which method of a Frame is used to set the layout manager?
A. setLayout()
B. add()
C. actionPerformed()
D. setVisible()
Answer optiona
Marks: 1
1. public void itemStateChanged(ItemEvent ie ) {
2. JCheckBox cb = (JCheckBox) ie.getItem( );
3. int state ie.getStateChange( );
4. // Line no 4
839 5. System.out.println(cb.getText( ) + "selected");
6. else
7. System.out.println(cb.getText( ) + "cleared");
8. }
Identify correct code at line no 4
A. if (state == ItemEvent.Change)
B. if (state == ItemEvent.Modified)
C. if (state == ItemEvent.SELECTED)
D. if (state == ItemEvent.getText)
Answer optionc
Marks: 1
840 Which are the not types of key events-
A. KEY_PRESSED
B. KEY_DOUBLE
C. KEY_RELEASED
D. KEY_TYPED
Answer optionb
Marks: 1
841 Interface MouseMotionListener belongs to _____________ package.
A. java.listener
B. java.util.event
C. java.awt.event
D. java.motion
Answer optionc
Marks: 1
842 _____________is the super class of all event classes.
A. Event
B. Object
C. EventObject
D. EventClass
Answer optionc
Marks: 1
843 Which of this interface is defines a method adjustmentValueChanged( )
A. ComponentListener
B. ContainerListener
C. ItemStateListener
D. AdjustmentListener
Answer optiond
Marks: 1
844 Which of these interfaces define a method keyPressed()?
A. MouseMotion Listener
B. MouseListener
C. KeyBoardListener
D. KeyListener
Answer optiond
Marks: 1
845 From following options which of these is method of MouseMotionListener
A. mouseMoved()
B. MouseMotionListener()
C. MouseClick()
D. MousePressed()
Answer optiona
Marks: 1
Fill in the blank:
846 MouseMotionListener interface defines___________methods
A. one
B. two
C. three
D. four
Answer optionb
Marks: 1
847 A source is an ________ that generates an event .
A. class
B. interface
C. object
D. variable
Answer optionc
Marks: 1
Assuming we have a class which implements the ActionListener interface
848 should be used to register this with a Button? ;
A. addListener(*)
B. addActionListener(*);
C. addButtonListener(*);
D. setListener(*);
Answer optionb
Marks: 1
849 windowGainedFocus() and windowLostFocus() methods are belongs to _____
A. WindowInterface
B. WindowFocused Interface
C. WindowFocusListener
D. WindowAction Interface
Answer optionc
Marks: 1
Fill in the blank:
850 MouseListener interface define…........methods
A. 2
B. 5
C. 7
D. 4
Answer optionb
Marks: 1
851 KEY_TYPED Event generated when....
A. key pressed or released
B. only when character is generated
C. only key pressed
D. only key released
Answer optionb
Marks: 1
852 Which of these methods are used to register a Window listener?
A. windowListener()
B. addListener()
C. addWindowListener()
D. eventWindowListener()
Answer optionc
Marks: 1
853 Which of these methods are used to register a mouse motion listener?
A. addMouse()
B. addMouseListener()
C. addMouseMotionListner()
D. eventMouseMotionListener()
Answer optionc
Marks: 1
KeyEvent Constructor-
854 KeyEvent(Component src, int type, long when, int modifiers, int code
Here when means-
A. a reference to the component that generated the event.
B. The type of event occured.
C. virtual key codes
D. The system time at which the key was pressed.
Answer optiond
Marks: 1
855 What is a listener in context to event handling?
A. A listener is a variable that is notified when an event occurs.
B. A listener is a object that is notified when an event occurs.
C. A listener is a method that is notified when an event occurs.
D. None of the mentioned.
Answer optionb
Marks: 1
856 The KeyEvent class methods-
A. getKeyCode ( )
B. geyKeyTyped( )
C. getKeyChar ( )
D. both a and c
Answer optiond
Marks: 1
857 Which of these are methods of TextListener Interface?
A. textChange()
B. textModified()
C. textValueChanged()
D. textValueModified()
Answer optionc
Marks: 1
858 If no valid character is available then geyKeyChar( ) returns-
A. VK_UNDEFINED
B. CHAR_UNDEFINED
C. VK_CONTROL
D. CHAR_ERROR
Answer optionb
Marks: 1
859 Which of these are methods of KeyListener Interface?
A. keyPressed()
B. keyReleased()
C. keyTyped()
D. All of this
Answer optiond
Marks: 1
860 KeyEvent is a subclass of-
A. InputEvent
B. TextEvent
C. ItemEvent
D. MouseEvent
Answer optiona
Marks: 1
861 Which source generates adjustment events?
A. Button
B. List
C. Scroll bar
D. Text components
Answer optionc
Marks: 1
DatagramPacket(byte data[ ], int size)
862 DatagramPacket(byte data[ ], int offset, int size) are examples of----
A. package
B. class
C. Interface
D. constructors
Answer optiond
Marks: 1
863 ___________ method is used to register a Component listener.
A. addMouse()
B. addComponentListener( )
C. addMouseMotionListener()
D. eventMouseMotionListener()
Answer optionb
Marks: 1
MouseEvent Constructor-
MouseEvent(Component src, in type, long when, int modifiers, int x, i
864 boolean triggersPopup)
Here x and y means-
A. co-ordinates of the mouse passed
B. The click count
C. Reference to the component
D. The system time at which the mouse event occured.
Answer optiona
Marks: 1
865 getPoint( ) , method to obtain ...................................
A. x - co-ordinates of the mouse.
B. y- co-ordinates of the mouse.
C. both x and y co-ordinates of the mouse.
D. The total number of click count.
Answer optionc
Marks: 1
The following statement return-
866 Point getPoint( )
A. to obtain the coordinates of the mouse.
B. returns Point int that contains the Y
C. returns Point object that contains the X
D. to obtain the coordinates of the key
Answer optiona
Marks: 1
867 The, int getClickCount( ) method returns-
A. number of mouse clicks for widgets.
B. number of mouse clicks for graphical user interface.
C. number of mouse clicks for this event.
D. number of mouse clicks from application started.
Answer optionc
Marks: 1
868 The isPopupTrigger( ) methods returns-
A. int
B. void
C. object
D. boolean
Answer optiond
Marks: 1
869 The, getButton( ) method returns-
A. returns int value that represents the button that caused the event.
B. returns boolean value that represents the button that caused the event
C. returns void and generates events.
D. returns object and generates events.
Answer optiona
Marks: 1
870 The __________interface handles item event.
A. ActionListener
B. ItemListener
C. ItemHandler
D. WindowListener
Answer optionb
Marks: 1
871 Which method not use to obtain the coordinates of the mouse-
A. Point getLocationOnScreen( )
B. int getKeyCode( )
C. int getXOnScreen( )
D. int getYOnScreen( )
Answer optionb
Marks: 1
872 Which of these method are used to register a keyboard event Listener
A. KeyListener()
B. addKeyListener()
C. RegisterKeyListener()
D. addKeyBoard()
Answer optionb
Marks: 1
873 The TextEvent generated by-
A. text fields and text areas when characters are entered.
B. text fields and text areas when mouse entered.
C. text fields and text areas when mouse clicked
D. text fields and text areas when keyboard press.
Answer optiona
Marks: 1
874 Which is the correct general form of method of the ActionListener int
A. void ActionPerformed(ActionEvent ae)
B. void ActionPerformed(Actionevent ae)
C. void actionPerformed(ActionEvent ae)
D. void ActionPerformed(actionEvent ae)
Answer optionc
Marks: 1
The TextEvent Constructor-
875 TextEvent(Object src, int type)
Here type means-
A. The type of text
B. The type of object passed.
C. The type of event.
D. The type of source generated events.
Answer optionc
Marks: 1
876 keyTyped() is method of __________ interface.
A. KeyBoard Interface
B. Mouse Interface
C. WindowListener Interface
D. KeyListener Interface
Answer optiond
Marks: 1
877 keyPressed() is method of __________ interface.
A. KeyBoard Interface
B. Mouse Interface
C. WindowListener Interface
D. KeyListener Interface
Answer optiond
Marks: 1
878 keyReleased() is method of __________ interface.
A. KeyBoard Interface
B. Mouse Interface
C. WindowListener Interface
D. KeyListener Interface
Answer optiond
Marks: 1
879 windowDeiconified() is method of ________interface
A. WindowListener Interface
B. Window Interface
C. Window Conified Interface
D. Action Interface
Answer optiona
Marks: 1
880 windowIconified() is method of ________interface
A. WindowListener Interface
B. Window Interface
C. WindowConified Interface
D. Action Interface
Answer optiona
Marks: 1
881 WindowActivated() is method of ________interface.
A. WindowListener Interface
B. Window Interface
C. Window Activated Interface
D. Action Interface
Answer optiona
Marks: 1
882 windowClosed() is method of ________interface.
A. WindowListener Interface
B. Window Interface
C. WindowClosed Interface
D. Action Interface
Answer optiona
Marks: 1
883 windowClosing() is method of ________interface
A. WindowListener Interface
B. Window Interface
C. WindowConified Interface
D. Action Interface
Answer optiona
Marks: 1
When a ------------- Dialog box is active, it blocks user input to all
884 the program.
A. modal
B. modeless
C. file
D. none of the above
Answer optiona
Marks: 1
Find the missing Statements in the following program to get the given
import java.awt.*;
import java.awt.event.*;
885 public class DialogEx extends WindowAdapter implements ActionListener
{
Frame frame;
Label label1;
TextField field1;
Button button1, button2, button3;
Dialog d1, d2, d3;
DialogEx()
{
frame = new Frame("Frame");
button1 = new Button("Open Modal Dialog");
label1 = new Label("Click on the button to open a Modal Dialog");
frame.add(label1);
frame.add(button1);
button1.addActionListener(this);
frame.pack();
frame.setLayout(new FlowLayout());
frame.setSize(330,250);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getActionCommand().equals("Open Modal Dialog"))
{
---------------------------------------
Label label= new Label("You must close this dialog window to use Frame
window",Label.CENTER);
d1.add(label);
d1.addWindowListener(this);
d1.pack();
d1.setLocationRelativeTo(frame);
d1.setLocation(new Point(100,100));
d1.setSize(400,200);
---------------------------------------
}
}
public void windowClosing(WindowEvent we)
{
d1.setVisible(false);
}
public static void main(String...ar)
{
new DialogEx();
}
}
A. d1= new Dialog(frame,"Modal Dialog",true);
B. d1.setVisible(true);
C. d1= new Dialog(frame,"Modal Dialog",true); d1.setVisible(true);
D. d1= new Dialog(frame,"Modal Dialog",true);d1.setVisible(false);
Answer optionc
Marks: 2
Following method returns true if a cookie contains the session ID. Oth
886 false.
A. boolean RequestedSessionIdFromCookie( )
B. boolean isRequestedSessionId( )
C. boolean isRequestedFromCookie( )
D. boolean isRequestedSessionIdFromCookie( )
Answer optiond
Marks: 1
Which of the following method returns true if the URL contains the se
887 Otherwise, returns false.
A. boolean isRequestedSessionIdFromURL( )
B. int requestedSessionIdFromURL( )
C. boolean isRequestedSessionIdFromcookie( )
D. int isRequestedSessionIdFromURL( )
Answer optiona
Marks: 1
_________ method returns true if the requested session ID is valid in
888 context.
A. boolean RequestedSessionIdValid( )
B. boolean isRequestedSessionId( )
C. boolean isRequestedValid( )
D. boolean isRequestedSessionIdValid( )
Answer optiond
Marks: 1
Which of the following method returns the session for this request. I
889 not exist, one is created and then returned.
A. httpsession getsession( )
B. HttpServlet getSession( )
C. HttpSession getSession( )
D. Session getsession( )
Answer optionc
Marks: 1
890 Text Fields is also know as ___________
A. Single line control
B. Active Control
C. Passive Control
D. Edit Control
Answer optiond
Marks: 1
All the methods of HttpSession interface throw an _____________ if the
891 already been invalidated.
A. IllegalState
B. IllegalException
C. LegalStateException
D. IllegalStateException
Answer optiond
Marks: 1
Following method returns an enumeration of the attribute names associa
892 session..
A. Enumeration getAttributeNames( )
B. String getAttributeNames( )
C. void getAttributeNames( )
D. none of the above
Answer optiona
Marks: 1
893 Echoing of characters can be disabled as they are typed by using______
A. echoChar()
B. isEchochar()
C. setEchochar()
D. echoCharIsSet()
Answer optionc
Marks: 1
Following method returns the time (in milliseconds since midnight, Jan
894 when this session was created.
A. int getcreationtime( )
B. long CreationTime( )
C. long getCreationTime( )
D. long getCreation( )
Answer optionc
Marks: 1
895 JChoice control of swings is a kind of_____________
A. Menu
B. Item
C. Radio
D. List
Answer optiona
Marks: 1
896 Which of the following method invalidates the session and removes it
A. String invalidate( )
B. void invalidate( )
C. int invalidate( )
D. void setinvalidate( )
Answer optionb
Marks: 1
897 JLabels are ____________ Control.
A. Active
B. User
C. Passive
D. Interactive
Answer optionc
Marks: 1
Which of the following classes represents event notifications for cha
898 within a web application
A. Cookie
B. HttpServlet
C. HttpSessionEvent
D. HttpSessionBindingEvent
Answer optionc
Marks: 1
899 Which Property is wrong for JLabel
A. Label.LEFT
B. Label.CENTER
C. Label.RIGHT
D. Label.BOTTOM
Answer optiond
Marks: 1
900 URLEncoder , URLConnection , URLDecoder are examples of
A. package
B. class
C. interface
D. method
Answer optionb
Marks: 1
901 ContentHandlerFactory , CookiePolicy,CookieStore are examples of
A. package
B. class
C. interface
D. method
Answer optionc
Marks: 1
Which of the following are the different methods of ResultSet interfac
1. public boolean next()
902 2. public boolean previous()
3. public boolean back()
4. public boolean last()
A. 1,2,3
B. 1,2,4
C. 2,3,4
D. All of the above.
Answer optionb
Marks: 1
Which of the following are the different methods of Statement interfac
1. public int[] executeBatch()
903 2. public boolean execute(String sql)
3. public int executeUpdate(String sql)
4. public int insert(String sql)
A. 1,2,3
B. 2,3,4
C. 1,3,4
D. All of the above.
Answer optiona
Marks: 1
Consider the following program, Select the statement that should be ad
to get correct output.
import java.sql.*;
public class MyData
{
public static void main(String args[])throws Exception
904 {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:MyDSN","",""); Pre
s=c.prepareStatement( "update student set Name=* where Roll_no=*"); s.
s.setString(2,"1"); s.executeUpdate();
s.close();
c.close(); } }
A. a. use s.executeQuery() method
B. Use ; in main method
C. Use s.setString(2,1) method
D. use ? in PreparedStatement
Answer optiond
Marks: 2
6. Which is the incorrect statement in the following Code?
import java.sql.*; public class Sample1 { public static void main(Str
Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
=DriverManager.getConnection("jdbc:odbc:DSN2","",""); PreparedStatemen
905 s=c.createStatement( ); ResultSet rs=s.executeQuery("select* from stud
System.out.println("Name"+" "+"Roll no"+" "+"Avg"); while(rs.next(
System.out.println(rs.getString(1)+" "+rs.getInt(2)+" "+rs.getDo
s.close(); c.close(); } }
A. ResultSet rs=s.executeQuery();
B. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
C. PreparedStatement s=c.createStatement();
D. None of the above
Answer optionc
Marks: 2
Consider the following program. What should be the correction done in
correct output?
import java.sql.*; public class DataBase{ public static void main(Str
906 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn =
DriverManager.getConnection("jdbc:odbc:abc", "", ""); String s1="inser
values(1,'abc'); s.executeUpdate(s1); s.close(); conn.close();}catch(I
e){System.out.println(e);} } }
A. Insert try and catch(FileNotFoundException fe)
B. Use s.executeQuery(s1);
C. Insert try and catch(Exception e)
D. Insert catch(Exception e)
Answer optionc
Marks: 2
Fill in the blanks respectively.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
907 public class GetCookiesServlet extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{
Cookie[] cookies = request._____________;
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>");
for(int i = 0; i < cookies.length; i++) {
String name = cookies[i].______________;
String value = cookies[i].____________ ;
pw.println("name = " + name + "; value = " + value);
}
pw.close();
}
}
A. getname(); getvalue(); getcookies();
B. doHead(); doOptions(); doTrace()
C. service(); doHead(); doTrace();
D. getCookies(); getName(); getValue();
Answer optiond
Marks: 2
Fill in the blanks at the line number 4 and 8 respectively.
1. import java.io.*;
2. import javax.servlet.*;
3. import javax.servlet.http.*;
4. public class GetCookiesServlet extends __________ {
5. public void doGet(HttpServletRequest request, HttpServletRespons
908 ServletException, IOException {
6. Cookie[] cookies = request.getCookies();
7. response.setContentType(""text/html"");
8. PrintWriter pw =__________.getWriter();
9. pw.println(""<B>"");
10. for(int i = 0; i < cookies.length; i++) {
11. String name = cookies[i].getName();
12. String value = cookies[i].getValue();
13. pw.println(""name = "" + name + ""; value = "" + value);
14. }
15. pw.close();
16. }
17. }
A. GenericServlet , request
B. HttpServlet , response
C. HttpServlet , request
D. GenericServlet , response
Answer optionb
Marks: 2
What will be the output of the following program.
import java.sql.*;
import java.io.*;
public class RetrieveImage {
public static void main(String[] args) {
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
PreparedStatement ps=con.prepareStatement("select * from imgtable");
ResultSet rs=ps.executeQuery();
909 if(rs.next()){
Blob b=rs.getBlob(2); data
byte barr[]=b.getBytes(1,(int)b.length());
FileOutputStream fout=new FileOutputStream("d:\picture.jpg");
fout.write(barr);
fout.close();
}//end of if
con.close();
}catch (Exception e) {e.printStackTrace(); }
}
}
A. image will be inserted into the database
B. Image will be retrieved from the database.
C. ; missing
D. } missing
Answer optionb
Marks: 2
setAttribute( ), getAttribute( ), getAttributeNames( ), and removeAttr
910 ____________ interface.
A. HttpSession
B. HttpServlet
C. HttpServletResponse
D. HttpServletRequest
Answer optiona
Marks: 1
import java.awt.*;
import java.applet.*;
public class checkboxDemo extends Applet
911 /* <applet code="checkboxDemo" width=300 height=300></applet>*/
{
public void init()
{
Checkbox cb1,cb2;
CheckboxGroup cbg=new CheckboxGroup();
cb1=new Checkbox("Java",true,cbg);
cb2=new Checkbox("C++",false,cbg);
add(cb1);add(cb2);
}
}
What is expected output of above code ?
A. Creates two checkboxes named "Java" and "C++"
B. Creates two radio buttons with "Java" and "C++" with "Java" button as
C. Creates two radio buttons with "Java" and "C++" with "C++" button as s
D. None of these
Answer optionb
Marks: 2
void setPath(String p)
void setSecure(boolean secure)
912 void setValue(String v)
void setVersion(int v)
Identify the class where above methods belong to.
A. HttpSession
B. HttpServlet
C. Cookie
D. GenericServlet
Answer optionc
Marks: 1
import java.awt.*;
import javax.swing.*;
public class LayoutDemo{
JFrame f;
LayoutDemo(){
f=new JFrame();
JButton b1=new JButton("1");
JButton b2=new JButton("2");
JButton b3=new JButton("3");
JButton b4=new JButton("4");
JButton b5=new JButton("5");
913
f.add(b1);f.add(b2);f.add(b3);f.add(b4);f.add(b5);
f.setLayout(new FlowLayout(FlowLayout.RIGHT));
//setting flow layout of right alignment
f.setSize(300,300);
f.setVisible(true);
}
public static void main(String[] args) {
new LayoutDemo();
}
}
Find the output.
A.
B.
C.
D.
Answer optionc
Marks: 2
Select correct option to get the proper output:
import java.awt.*;
import java.applet.*;
public class LayoutDemo extends Applet
{
static final int n = 4;
public void init()
{
setLayout(new GridLayout(n, n));
setFont(new Font("SansSerif", Font.BOLD, 24));
for(int i = 0; i < n; i++)
914 {
for(int j = 0; j <n; j++)
{
int k = i * n + j;
if(k > 0)
add(new Button("" + k));
}
}
}
}
/*<applet code="LayoutDemo.class" width=100 height=100></applet>*/
A.
B.
C.
D.
Answer optiona
Marks: 2
915 Which of the following statement is used for connectivity with Oracle
A. Connection
con=DriverManager.getConnection("odbc:oracle:thin:@localhost:1512:xe",
Connection
B. con=DriverManager.getConnection("jdbc:thin:oracle:@localhost:1512:xe",
Connection
C. con=DriverManager.getConnection("odbc:oracle:thin:@localhost:1521:xe",
Connection
D. con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe",
Answer optiond
Marks: 1
916 Which layout is used to align fixed width components at the edges?
A. java.awt.BorderLayout
B. java.awt.FlowLayout
C. java.awt.GridLayout
D. java.awt.CardLayout
Answer optiona
Marks: 1
917 Which of the following class is used to apply the grid layout?
A. java.awt.BorderLayout
B. java.awt.FlowLayout
C. java.awt.GridLayout
D. java.awt.CardLayout
Answer optionc
Marks: 1
918 -------------------- class is used to apply flow layout.
A. java.io.FlowLayout
B. java.awt.FlowLayout
C. javax.awt.GridLayout
D. javax.awt.CardLayout
Answer optionb
Marks: 1
Which of the following methods are used to navigate through the differ
919 layout?
A. public void next(Container parent)
B. public void previous(Container parent)
C. public void first(Container parent)
D. All of the above
Answer optiond
Marks: 1
920 Which of the following method is used to show the specific card?
A. public void show(Container parent, String name)
B. public void show(Container parent)
C. public void first(Container parent, String name)
D. public void next(Container parent, String name)
Answer optiona
Marks: 1
We can control the alignment of components in a flow layout arrangemen
921 ----- FlowLayout Fields.
A. FlowLayout.RIGHT
B. FlowLayout.LEFT
C. FlowLayout.CENTER
D. All of the above
Answer optiond
Marks: 1
922 Identify the Layout and alignment of components in the given output.
A. FlowLayout and LEFT alignment
B. FlowLayout and RIGHT alignment
C. GridLayout and LEFT alignment
D. GridLayout and RIGHT alignment
Answer optionb
Marks: 1
Consider the following code. Fill the proper method in the blank space
of total records updated.
import java.sql.Statement;
public class MyExecuteMethod {
public static void main(String a[] ){
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.
getConnection
getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","oracle")
Statement stmt = con.createStatement();
//The query can be update query or can be select query
String query = "select * from emp";
boolean status = stmt.execute(query);
923 if(status){
ResultSet rs = stmt.getResultSet();
while(rs.next()){
System.out.println(rs.getString(1));
}
rs.close();
} else {
int count = stmt.-------------------------;
System.out.println("Total records updated: "+count);
}
}
catch (SQLException e) { e.printStackTrace();}
}
}
A. getUpdateCount();
B. getCount();
C. readCount();
D. readUpdateCount();
Answer optiona
Marks: 2
924 Identify the layout in the given output.
A. BorderLayout
B. GridLayout
C. GridBagLayout
D. CardLayout
Answer optionb
Marks: 1
925 insert() is the method of _____ class.
A. TextArea
B. TextField
C. Button
D. None of above
Answer optiona
Marks: 1
926 A programmer uses a Java class known as ___________ to connect to a d
A. JDBC driver
B. Package
C. JDBC Interface
D. none of the Above
Answer optiona
Marks: 1
927 Identify the layout in the given output.
A. BorderLayout
B. GridLayout
C. GridBagLayout
D. CardLayout
Answer optionc
Marks: 1
928 ____________ is a call-level interface.
A. Oracle's Oracle Call Interface (OCI)
B. Microsoft's Open Database Connectivity (ODBC)
C. JDBC
D. All of the Above
Answer optiond
Marks: 1
929 Identify the layout in given output.
A. BorderLayout
B. GridLayout
C. FlowLayout
D. CardLayout
Answer optionc
Marks: 1
930 Because of ________ coupling a 2 tiered application will run ________.
A. loose, faster
B. tight, faster
C. loose, slower
D. tight, slower
Answer optionb
Marks: 1
931 Which of the following code is used to retrieve auto generated primary
public class MyAutoGeneratedKeys { public static void main(String
{ Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager. getConnection
getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","oracle")
String query = "insert into emps (name, dept, salary) values (?,?,?)";
A. PreparedStatement pstmt = con.prepareStatement(query,Statement.RETURN
pstmt.setString(1, "John"); pstmt.setString(2, "Acc Dept")
pstmt.setInt(3, 10000); pstmt.executeUpdate();
pstmt.putGeneratedKeys(); if(rs != null && rs.next()){
System.out.println("Generated Emp Id: "+rs.getInt(1)); }
(SQLException e) { e.printStackTrace();}}}
public class MyAutoGeneratedKeys { public static void main(String
{ Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager. getConnection
getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","oracle")
String query = "insert into emps (name, dept, salary) values (?,?,?)";
B. PreparedStatement pstmt = con.prepareStatement(query,Statement.RETURN
pstmt.setString(1, "John"); pstmt.setString(2, "Acc Dept")
pstmt.setInt(3, 10000); pstmt.executeUpdate();
pstmt.getAutoGeneratedKeys(); if(rs != null && rs.next()){
System.out.println("Generated Emp Id: "+rs.getInt(1)); }
(SQLException e) { e.printStackTrace();}}}
public class MyAutoGeneratedKeys { public static void main(String
{ Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager. getConnection
getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","oracle")
String query = "insert into emps (name, dept, salary) values (?,?,?)";
C. PreparedStatement pstmt = con.prepareStatement(query,Statement.RETURN
pstmt.setString(1, "John"); pstmt.setString(2, "Acc Dept")
pstmt.setInt(3, 10000); pstmt.executeUpdate();
pstmt.getKeys(); if(rs != null && rs.next()){
System.out.println("Generated Emp Id: "+rs.getInt(1)); }
(SQLException e) { e.printStackTrace();}}}
public class MyAutoGeneratedKeys { public static void main(String
{ Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager. getConnection
getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","oracle")
String query = "insert into emps (name, dept, salary) values (?,?,?)";
D. PreparedStatement pstmt = con.prepareStatement(query,Statement.RETURN
pstmt.setString(1, "John"); pstmt.setString(2, "Acc Dept")
pstmt.setInt(3, 10000); pstmt.executeUpdate();
pstmt.getGeneratedKeys(); if(rs != null && rs.next()){
System.out.println("Generated Emp Id: "+rs.getInt(1)); }
(SQLException e) { e.printStackTrace();}}}
Answer optiond
Marks: 2
932 Which of the Following is NOT true for Two Tier Architecture
A. The direct communication takes place between client and server.
B. There is no intermediate between client and server.
C. A 2 tiered application will run faster.
D. In two tier architecture the server can respond multiple request same
Answer optiond
Marks: 1
933 Which of the following methods are used to set the Hgap and Vgap in fl
A. setHgap (int)
B. int setVgap (int), int setHgap (int)
C. void setHgap (int),void setVgap (int)
D. None of the above
Answer optionc
Marks: 1
934 A driver is used to ___________ to a particular database.
A. issue sql queries
B. open a connection
C. load database
D. load resultset
Answer optionb
Marks: 1
935 ----------------method is used to set the alignment in flow layout.
A. setAlignment (int)
B. getAlignment ()
C. setAlignment ()
D. getAlignment (int)
Answer optiona
Marks: 1
936 The core API in java.sql consists of ___ interfaces, ___ classes, and
A. 16, 8
B. 32,8
C. 8, 4
D. 32,4
Answer optiona
Marks: 1
937 By using which interface one can store images in the database in java
A. ResultSet interface
B. PreparedStatement interface
C. Connection interface
D. None of the above
Answer optionb
Marks: 1
938 The constructors in BorderLayout class are------------
A. BorderLayout()
B. BorderLayout(int hgap, int vgap)
C. Both a and b
D. None of the above
Answer optionc
Marks: 1
939 The core API in java.sql consists of ___ interfaces, 8 classes, and __
A. 8, 4
B. 16, 8
C. 4, 4
D. 16, 4
Answer optiond
Marks: 1
940 The constructors in GridLayout class are-----------
A. GridLayout()
B. GridLayout(int rows, int cols)
C. GridLayout(int rows, int cols, int hgap, int vgap)
D. All of the above
Answer optiond
Marks: 1
941 The JDBC interface is contained in the......
A. java.sql Package
B. javax.sql Package
C. Both of the Above
D. None of the Above
Answer optionc
Marks: 1
942 Which method is used to find out the number of rows in the grid layou
A. int getRows()
B. void getRows()
C. void getRows(int)
D. None of the above
Answer optiona
Marks: 1
943 The----------method is used to know number of columns in the grid layo
A. int getColumns()
B. void getColumns()
C. void getColumns(int)
D. None of the above
Answer optiona
Marks: 1
TextArea a2=new TextArea("Advanced is multitasking",5,30);
944 Which method is used to get output as "Advanced Java is multitasking."
A. insert("Java ",9)
B. append("Java",9)
C. getRows("Java",10)
D. None of these
Answer optiona
Marks: 1
The ------------------ and ----------------- methods are used to set t
945 and columns in the grid layout respectively.
A. void setRows(int rows) , void setColumns(int cols)
B. void setColumns(int cols)
C. void setColumns(int cols), void setRows(int rows)
D. void setRows(int rows)
Answer optiona
Marks: 1
946 Identify the layout in given output
A. BorderLayout
B. GridLayout
C. FlowLayout
D. CardLayout
Answer optionc
Marks: 1
947 Identify the layout in given output
A. BorderLayout
B. GridLayout
C. FlowLayout
D. CardLayout
Answer optiona
Marks: 1
948 Identity the Driver in the Figure
A. Type 1 Driver
B. Type 2 Driver
C. Type 3 Driver
D. Type 4 Driver
Answer optiona
Marks: 1
949 To execute a statement ,we invoke method_________
A. executeUpdate()
B. executeRel()
C. executeStmt()
D. exectuteCon()
Answer optiona
Marks: 1
950 The -------------------- constructor is used to create FileDialog with
A. FileDialog(Dialog parent)
B. FileDialog(Dialog parent, String title)
C. FileDialog(Frame parent)
D. None of the above
Answer optionb
Marks: 1
951 Identify the Type of Following Driver
A. Type 1 Driver
B. Type 2 Driver
C. Type 3 Driver
D. Type 4 Driver
Answer optionc
Marks: 1
952 Identify the JDBC Driver
A. Type 1 Driver
B. Type 2 Driver
C. Type 3 Driver
D. Type 4 Driver
Answer optiond
Marks: 1
953 Which of the Following is Type 1 Driver
A.
B.
C.
D.
Answer optiona
Marks: 1
954 Which of the Following is Type 2 Driver
A.
B.
C.
D.
Answer optionb
Marks: 1
955 Identify the Type 3 Driver From the following Figures
A.
B.
C.
D.
Answer optionc
Marks: 1
956 Identify the Type 4 Driver From the following Figures
A.
B.
C.
D.
Answer optiond
Marks: 1
Consider Following Program
import java.sql.*;
public class JdbcSelectTest
{
957 public static void main(String args[]){
try {
---------------------------------------------
Statement stmt = conn.createStatement();
String strSelect = "select rollno, name, marks from student";
System.out.println("The SQL query is: " + strSelect);
ResultSet rset = stmt.executeQuery(strSelect);
System.out.println("The records selected are:");
int rowCount = 0;
while(rset.next()) {
String rollno = rset.getString("rollno");
String name = rset.getString("name");
int marks = rset.getInt("marks");
System.out.println(rollno + ", " + name + ", " + marks);
++rowCount;
}
System.out.println("Total number of records = " + rowCount);
conn.close();
}
catch(SQLException ex) {
ex.printStackTrace();
}
}
}
Chose correct response to fill the blank.
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:
A. "root", "root");
Connection conn; conn =
B. DriverManager.getConnection("jdbc:mysql://localhost:3306/mydata", "sco
Connection conn = DriverManager.getConnection("jdbc:mysql://192.168.1
C. "root", "root");
D. All of the Above
Answer optiond
Marks: 1
Consider following Program
958 import java.sql.*;
public class JdbcSelectTest
{
public static void main(String args[]){
try {
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/mydata", "roo
Statement stmt = conn.createStatement();
String strSelect = "select rollno, name, marks from student";
System.out.println("The SQL query is: " + strSelect);
ResultSet rset = stmt.executeQuery(strSelect);
System.out.println("The records selected are:");
int rowCount = 0;
while(rset.next()) {
String rollno = _____________________;
String name = rset.getString("name");
int marks = _____________________;
System.out.println(rollno + ", " + name + ", " + marks);
++rowCount;
}
System.out.println("Total number of records = " + rowCount);
conn.close();
}
catch(SQLException ex) {
ex.printStackTrace();
}
}
}
Choose Correct Option to replace Blank
A. rs.getInt(
B. rset.getString(1); & rset.getInt(3);
C. stmt.getString(
D. Both A and B
Answer optionb
Marks: 1
Fill in the blanks to insert values in Student(rollno,name,marks,conta
import java.sql.*;
public class SampleInsert {
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
959 Connection c =DriverManager.getConnection("jdbc:odbc:DSN2","",""); Pre
s=c.prepareStatement("______" ); int n=s. .executeUpdate();
Statement st=con.createStatement();ResultSet rs=st.executeQuery("selec
System.out.println("Name"+" "+"Roll no"+" "+"Avg");
while(rs.next()) { System.out.println(rs.getInt(1)+" "+rs.getString(2)
"+rs.getDouble(3) +" "+rs.getInt(4)); } s.close(); c.close
A. Insert into student values(?,?,?)
B. Insert into table student (?,?,?,?)
C. Insert into table student values(?,?,?)
D. Insert into student values(?,?,?,?)
Answer optiond
Marks: 2
960 The ----------- method is used to move to the first card in card layou
A. public void previous(Container parent)
B. public void first(Container parent)
C. public void next(Container parent)
D. All of the above
Answer optionb
Marks: 1
Predict the output of Following program
import java.sql.*;
public class JdbcSelectTest
{
public static void main(String args[]){
try {
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/mydata", "roo
Statement stmt = conn.createStatement();
String strSelect = "select rollno, name, marks from student";
System.out.println("The SQL query is: " + strSelect);
ResultSet rset = stmt.executeQuery(strSelect);
System.out.println("The records selected are:");
int rowCount = 0;
961 while(rset.first()) {
String rollno = rset.getString("rollno");
String name = rset.getString("name");
int marks = rset.getInt("marks");
System.out.println(rollno + ", " + name + ", " + marks);
++rowCount;
}
System.out.println("Total number of records = " + rowCount);
conn.close();
}
catch(SQLException ex) {
ex.printStackTrace();
}
}
}
A. print all the columns of student table
B. print roll no, name and marks from student table
C. print roll no, name and marks of first student from student table
D. None of the Above
Answer optionc
Marks: 2
962 Which method is used to know the mode of the FileDialog.?
A. int getMode()
B. void getMode()
C. int getMode(int)
D. void getMode(int)
Answer optiona
Marks: 1
963 The ----------------- method is used to set the mode of the FileDialog
A. void setMode(int mode)
B. int setMode(int mode)
C. void setMode()
D. int setMode()
Answer optiona
Marks: 1
Consider Following Program
964 import java.sql.*;
public class JdbcSelectTest
{
public static void main(String args[]){
try {
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/mydata", "roo
Statement stmt = conn.createStatement();
String strSelect = "select rollno, name, marks from student";
System.out.println("The SQL query is: " + strSelect);
ResultSet rset = stmt.executeQuery(strSelect);
System.out.println("The records selected are:");
int rowCount = 0;
while(rset.next()) {
String rollno = rset.getString("rollno");
String name = rset.getString("name");
_____ marks = _______________;
System.out.println(rollno + ", " + name + ", " + marks);
++rowCount;
}
System.out.println("Total number of records = " + rowCount);
conn.close();
}
catch(SQLException ex) {
ex.printStackTrace();
}
}
}
Choose Correct Option to replace Blank.
A. int, rset.getInt
B. String, a.getString
C. Both of the Above
D. None of the Above
Answer optiona
Marks: 1
Predict the Output of following program
import java.sql.*;
public class JdbcSelectTest
{
public static void main(String args[]){
try {
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/mydata", "roo
Statement stmt = conn.createStatement();
String strSelect = "select rollno, name, marks from student";
System.out.println("The SQL query is: " + strSelect);
ResultSet rset = stmt.executeQuery(strSelect);
System.out.println("The records selected are:");
int rowCount = 0;
965 while(rset.last()) {
String rollno = rset.getString("rollno");
String name = rset.getString("name");
int marks = rset.getInt("marks");
System.out.println(rollno + ", " + name + ", " + marks);
++rowCount;
}
System.out.println("Total number of records = " + rowCount);
conn.close();
}
catch(SQLException ex) {
ex.printStackTrace();
}
}
}
A. print all the columns of student table
B. print roll no, name and marks from student table
C. print roll no, name and marks of last student from student table
D. generate sql Exception
Answer optionc
Marks: 1
966 _____class implements a single line text-entry area.
A. Button
B. TextField
C. Checkbox
D. TextArea
Answer optionb
Marks: 1
967 Return type for method next(), first() and last() method of resultset
A. int
B. String
C. boolean
D. ResultSet Object
Answer optionc
Marks: 1
Identify Correct Syntax for following method of ResulSet
968 ______ absolute (______);
A. boolean, int
B. boolean, void
C. void, int
D. void, void
Answer optiona
Marks: 1
Identify Correct Syntax for following method of ResulSet
969 ______ first (______);
A. boolean, int
B. boolean, void
C. void, int
D. void, void
Answer optionb
Marks: 1
Which is the correct syntax of next() method of
970 ResultSet() interface ?
A. boolean next()
B. void next()
C. void first()
D. void new()
Answer optiona
Marks: 1
971 Which driver provides JDBC access via one or more ODBC drivers
A. Type 1 driver
B. Type 2 driver
C. Type 3 driver
D. Type 4 driver
Answer optiona
Marks: 1
972 Which type of driver is called partly java driver?
A. Type 1 driver
B. Type 2 driver
C. Type 3 driver
D. Type 4 driver
Answer optionb
Marks: 1
__________ method of ResultSet object is called to retrieve Binary lar
973 database.
A. getBigDecimal
B. getBlob
C. getBinaryStream
D. getASCIIStream
Answer optionb
Marks: 1
What should be enter at the blank space?
import java.sql.*;
class PreparedUpdate
{
public static void main(String a[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:javadb");
974 Statement st=con.createStatement();
String stm = "update employee set name=? where name=?";
PreparedStatement ps = con.________________(stm);
ps.setString(1,"Ram");
ps.setString(2,"Ramesh");
ps.executeUpdate(stm);
ResultSet rs = st.executeQuery("select * from employee");
while(rs.next())
{
System.out.println(" ID : "+ rs.getInt(1));
System.out.println(" Name : "+ rs.getString(2));
System.out.println(" Salary : "+ rs.getInt(3));
System.out.println();
}
con.close();
}
catch(SQLException e)
{
System.out.println("SQL Error");
}
catch(Exception e)
{
System.out.println("Error");
}
}
}
A. PreparedStatement
B. ParameterizedStatement
C. prepareStatement
D. None of the above
Answer optionc
Marks: 2
Which statement should be missing in the following program?
class PreparedInsert
975 {
public static void main(String a[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:javadb");
System.out.println(" Connection to DataBase created");
String a1 = "Insert into employee(id,name,salary) values(?,?,?)";
PreparedStatement ps = con.prepareStatement(a1);
ps.setInt(1,5);
ps.setString(2,"sahil");
ps.setInt(3,5000);
ps.execute(a1);
System.out.println("Record Inserted");
String querySel = "Select * from employee";
ResultSet rs = ps.executeQuery(querySel);
System.out.println("After Insertion");
while(rs.next())
{
System.out.println(" ID : "+ rs.getInt(1));
System.out.println(" Name : "+ rs.getString(2));
System.out.println(" Salary : "+ rs.getInt(3));
System.out.println();
}
con.close();
}
catch(SQLException e)
{
System.out.println("SQL Error");
}
catch(Exception e)
{
System.out.println("Error");
}
}
}
A. Missing semicolon
B. Missing {
C. Missing }
D. Missing package statement.
Answer optiond
Marks: 2
976 Which AWT components are used to produce given output ?
A. Button,TextArea,Choice
B. List,TextArea,Label,Button
C. Label,TextField,Choice,CheckboxGroup
D. List,Label,TextField,Button
Answer optionc
Marks: 1
977 Return type of execute() method is _______
A. boolean
B. int
C. ResultSet
D. None of the Above
Answer optiona
Marks: 1
What should be added at the blank spaces?
import java.sql.*;
class ConnectDB
{
public static void main(String a[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver Loaded");
String url="jdbc:odbc:javadb";
978 __________________con=DriverManager.getConnection(url);
System.out.println(" Connection to DataBase created");
}
catch(SQLException e)
{
System.out.println(" Error"+e);
}
catch(Exception e)
{
System.out.println(" Error"+e);
}
}
}
A. DriverManager
B. Connection
C. Statement
D. None of the above
Answer optionb
Marks: 2
979 import java.awt.*;
import java.applet.*;
public class checkboxDemo extends Applet
/* <applet code="checkbox" width=300 height=300></applet>*/
{
public void init()
Checkbox cb1,cb2;
------------------------------------
cb1=new Checkbox("Java",true);
cb2=new Checkbox("C++",true,cbg);
add(cb1);add(cb2);
}
}
Fill in the blanks with correct statement.
A. CheckboxGroup cbg=new CheckboxGroup();
B. CheckboxGroup cbg=new CheckboxGroup(true);
C. CheckboxGroup cbg=new CheckboxGroup("Male",true);
D. None of the above
Answer optiona
Marks: 2
_____________ interface defines methods that enable user to send SQL q
980 data from the database.
A. Statement
B. Connection
C. DriverManager
D. None of the above
Answer optiona
Marks: 1
981 Which method moves record cursor to the next row of result set?
A. beforeFirst()
B. afterLast()
C. first()
D. next()
Answer optiond
Marks: 1
982 _____________object is used for precompiled SQL statements.
A. PreparedStatement
B. ParameterizedStatement
C. prepareStatement
D. None of the above
Answer optiona
Marks: 1
Identify Problem in the following code
import java.sql.*;
public class JdbcSelectTest
{
public static void main(String args[]){
Connection conn =
DriverManager.getConnection("jdbc:mysql://192.168.1.1:3306/mydata", "r
Statement stmt = conn.createStatement();
String strSelect = "select rollno, name, marks from student";
System.out.println("The SQL query is: " + strSelect);
ResultSet rset = stmt.executeQuery(strSelect);
983 System.out.println("The records selected are:");
int rowCount = 0;
while(rset.next()) {
String rollno = rset.getString("rollno");
String name = rset.getString("name");
int marks = rset.getInt("marks");
System.out.println(rollno + ", " + name + ", " + marks);
++rowCount;
}
System.out.println("Total number of records = " + rowCount);
}
}
A. Try catch not used
B. ResultSet object not created
C. wrong getConnection() method syntax
D. Both A&B
Answer optiona
Marks: 1
984 __________package contains the various interfaces and classes used by
A. java.sql
B. java.io
C. java.net
D. java.lang
Answer optiona
Marks: 1
985 windowDeactivated() is method of ________interface
A. WindowListener Interface
B. Window Interface
C. WindowConified Interface
D. Action Interface
Answer optiona
Marks: 1
986 windowOpened() is method of ________interface
A. WindowListener Interface
B. Window Interface
C. Window Conified Interface
D. Action Interface
Answer optiona
Marks: 1
987 mouseClicked() is method of _________interface.
A. Mouse Interface
B. MouseMotionListener Interface
C. MouseClick Interface
D. MouseListener Interface
Answer optiond
Marks: 1
988 mouseEntered() is method of _________interface .
A. Mouse Interface
B. MouseMotionListener Interface
C. MouseEntered Interface
D. MouseListener Interface
Answer optiond
Marks: 1
989 mouseExited() is method of _________interface.
A. Mouse Interface
B. MouseMotionListener Interface
C. MouseExited Interface
D. MouseListener Interface
Answer optiond
Marks: 1
990 mousePressed() is method of _________interface.
A. Mouse Interface
B. MouseMotionListener Interface
C. MousePressed Interface
D. MouseListener Interface
Answer optiond
Marks: 1
991 mouseReleased() is method of _________interface.
A. Mouse Interface
B. MouseMotionListener Interface
C. MouseReleased Interface
D. MouseListener Interface
Answer optiond
Marks: 1
Which of the following statements are true?
1) The MouseMotionListener interface defines methods for handling mou
992 2) The ActionListener interface defines methods for handling the clic
3) The MouseClickListener interface defines methods for handling mouse
4) The MouseListener interface defines methods for handling mouse dra
A. Statement 1 and 3 are true
B. Only first statement is true
C. Only second statement is true
D. All statements are true
Answer optionc
Marks: 1
Which of the following statements is true?
1) keyPressed() is method of KeyListerner Interface
993 2) keyPressed() is method of MouseListener Interface
3) keyPressed() is method of ActionListener Interface
4) keyPressed() is method of KeyBoardListener Interface
A. Statement 1 is true
B. Statement 2 is true
C. Statement 3 is true
D. Statement 4 is true
Answer optiona
Marks: 1
Which package is required for events?
994
A. java.listener
B. java.util.event
C. java.awt.event
D. java.motion
Answer optionc
Marks: 1
The Following steps are required to perform
995 1) Implement the Listener interface and overrides its methods
2) Register the component with the Listener
A. Exception Handling
B. String Handling
C. Event Handling
D. Listener Handling
Answer optionc
Marks: 1
Consider following three statement
1) ActionListener Interace defines one method to receive action event
996 2) ItemListener Interface defines one method to recognize when the st
change..
3) MouseListener interface defines mouseMoved() method
A. Statement 1 and 2 are true
B. Only first statement is true
C. Only second statement is true
D. All statements are true
Answer optiona
Marks: 1
Which of the following statements are false
1)windowlistener define seven method
997 2)mouseMotionListerne define 2 method
3) ActionListener Interace defines three method to receive action even
4)KeyListener Interface define Three method
A. Statement 1 is false
B. Statement 2 is false
C. Statement 3 is false
D. Statement 4 is false
Answer optionc
Marks: 1
Consider following two statement
1) Implement the Listener interface and overrides its methods is requi
998 event handling.
2) ActionListener Interace defines one method to receive action event
A. Only first statement is true
B. Only second statement is true
C. Both statements are true
D. Both statements are False
Answer optionc
Marks: 1
999 Which of the following method of a Frame is used to change it's color
A. setBackground(Color c )
B. setForeground( Color c )
C. add()
D. getBackground()
Answer optiona
Marks: 1
1000 ContentHandler , MulticastSocket , URL, SocketImpl are examples of --
A. package
B. class
C. Interface
D. Method
Answer optionb
Marks: 1
1001 URLEncoder , URLConnection , URLDecoder are examples of --------
A. package
B. class
C. Interface
D. All of the above
Answer optionb
Marks: 1
1002 The WindowEvent class, WINDOW_ICONIFIED, integer constants meaning-
A. Showing a window for the first time.
B. The window which contains the focus owner.
C. Reducing the window from to minimized.
D. Restoring the window to its original size.
Answer optionc
Marks: 1
ItemEvent constructor-
1003 ItemEvent(ItemSelectable src, int type, Object entry, int sta
Here src means......
A. The specific item that generated the item event is passed
B. The type of object
C. a reference to the component that generated event
D. The current state of that item.
Answer optionc
Marks: 1
1004 The WindowEvent class, WINDOW_DEICONIFIED, integer constants meaning-
A. Reducing the window to an icon on the desktop
B. The window which contains the focus owner.
C. Showing a window for the first time.
D. Restoring the window to its original size.
Answer optiond
Marks: 1
1005 Choose the incorrect statement ?
A. List l=new List(4);
B. List l1=new List(6,true);
C. Choice c=new Choice();
D. Choice c1=new Choice(3);
Answer optiond
Marks: 1
1006 What does URL stands for?
A. Uniform Resource Locator
B. Uniform Resource Latch
C. Universal Resource Locator
D. Universal Resource Latch
Answer optiona
Marks: 1
1007 The WindowEvent class, WINDOW_DEACTIVATED, integer constants meaning-
A. Reducing the window to an icon on the desktop
B. The window which contains the focus owner.
C. This window has lost the focus
D. Restoring the window to its original size.
Answer optionc
Marks: 1
Which of the following are true?
A. The event-inheritance model has replaced the event-delegation model
B. The event-inheritance model is more efficient than the event-delega
1008 C. The event-delegation model uses event listeners to define the metho
handling classes.
D. The event-delegation model uses the handleEvent( ) method to suppor
A. Statement 1 is true
B. Statement 2 is true
C. Statement 3 is true
D. Statement 4 is true
Answer optionc
Marks: 1
1009 WindowEvent is a subclass of __________________.
A. ComponentEvent
B. TextEvent
C. InputEvent
D. Window
Answer optiona
Marks: 1
1010 Which of these exceptions is thrown by URL classes constructors?
A. URLNotFound
B. URLSourceNotFound
C. MalformedURLException
D. URLNotFoundException
Answer optionc
Marks: 1
1011 Which of these methods is used to know host of an URL?
A. host()
B. getHost()
C. GetHost()
D. gethost()
Answer optionb
Marks: 1
WindowEvent Constructor-
1012 WindowEvent(Window src, int type, Window other, int fromState, int toS
Here fromState means-
A. the new state of the window
B. prior state of the window.
C. opposite window when a focus or activation event occurs.
D. reference to the object that generated this event.
Answer optionb
Marks: 1
1013 Which of the following components generate action events?
A. Button
B. Labels
C. Check boxes
D. Windows
Answer optiona
Marks: 1
1014 getWindow ( ) method returns
A. int value of window
B. Location of window
C. void value
D. Window object
Answer optiond
Marks: 1
Which of the following are true?
A) The MouseListener interface defines methods for handling mouse clic
1015 B) The MouseMotionListener interface defines methods for handling mous
C) The MouseClickListener interface defines methods for handling mouse
D) The ActionListener interface defines methods for handling the click
A. Only Statement A is true
B. Only Statement D is true
C. Statement A and D are true
D. Statement B and D are true
Answer optionc
Marks: 1
1016 WindowEvent class methods are-
A. getOppositeWindow()
B. getNewState()
C. getOldState()
D. All of above
Answer optiond
Marks: 1
1017 Which of these class is used to access actual bits or content informat
A. URL
B. URLDecoder
C. URLConnection
D. All of the mentioned
Answer optiond
Marks: 1
What is the output of this program?
import java.net.*;
class networking
{
1018 public static void main(String[] args) throws Malformed
{
URL obj = new URL("https://www.sanfoundry.com/javam
System.out.print(obj.getProtocol());
}
}
A. http
B. https
C. www
D. com
Answer optionb
Marks: 2
1019 Which of these methods is used to know the full URL of an URL object?
A. fullHost()
B. getHost()
C. ExternalForm()
D. toExternalForm()
Answer optiond
Marks: 1
Match the correct pairs-
a. getKeyLocation() i. Set the keyCode value to indic
b. getKeyCode() ii. Returns the character associ
in this event.
1020 c. getKeyChar() iii. Returns the location of t
originated this key event.
d. setKeyCode(int keyCode) iv. Returns the integer keyCode as
key in this event.
A. d-i, c-ii, a-iii, b-iv
B. d-ii, c-i, a-iii, b-iv
C. d-i, c-ii, a-iv, b-iii
D. d-iv, c-ii, a-iii, b-i
Answer optiona
Marks: 2
1021 Which of the following statements is true?
A. keyTyped() is method of KeyListerner Interface
B. keyTyped() is method of MouseListener Interface
C. keyTyped() is method of ActionListener Interface
D. keyTyped() is method of KeyBoardListener Interface
Answer optiona
Marks: 1
1022 .ContentHandlerFactory , SocketOptions , FileNameMap are included in
A. .net
B. .util
C. . io
D. .lang
Answer optiona
Marks: 1
1023 .com,.gov,.org are examples of--------
A. domain
B. server name
C. client name
D. package
Answer optiona
Marks: 1
1024 Which of the following option is true?
A. keyReleased() is method of KeyListerner Interface
B. keyReleased() is method of MouseListener Interface
C. keyReleased() is method of ActionListener Interface
D. keyReleased() is method of KeyBoardListener Interface
Answer optiona
Marks: 1
Consider following code segment-
1. public void keyReleased(getKeyChar( ) ) {
1025 2. str+=" -Key Released- ";
3. label2.setText(str);
4. jf.setVisible(true);
5. str="";
6.}
7. public void keyTyped(KeyEvent ke) {
8. str+=" -Key Typed- ";
9. label2.setText(str);
10. jf.setVisible(true);
11. }
Which statement is true ?
A. There are syntax errors on line no. 1
B. There are syntax errors on line no. 3
C. There are syntax errors on line no. 7
D. There are syntax errors on line no. 10
Answer optiona
Marks: 2
1026 Select true statement from the following options.
A. mousePressed() is method of MouseMotionListener Interface
B. mousePressed() is method of Mouse Interface
C. mousePressed() is method of MousePressed Interface
D. mousePressed() is method of MouseListener Interface
Answer optiond
Marks: 1
1027 Select correct general form of Mouse Clicked method of Mouse Listener
A. void mouseClicked(mouseEvent me)
B. void MouseClicked(mouseEvent me)
C. void MouseClicked(MouseEvent me)
D. void mouseClicked(MouseEvent me)
Answer optiond
Marks: 1
public void removeTypeListener(TypeListener el)
1028 Here Type means-
A. reference to the event listener
B. name of the event
C. type of multicasting of event
D. None of the above
Answer optionb
Marks: 1
1029 Which of these methods is used to know when was the URL last modified?
A. LastModified()
B. getLastModified()
C. GetLastModified()
D. getlastModified()()
Answer optionb
Marks: 1
1030 Which of these methods is used to know the type of content used in the
A. ContentType()
B. contentType()
C. getContentType()
D. GetContentType()
Answer optionc
Marks: 1
What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws Exception
1031 {
URL obj = new URL("https://www.sanfoundry.com/javamcq");
URLConnection obj1 = obj.openConnection();
System.out.print(obj1.getContentType());
}
}
A. html
B. text
C. html/text
D. text/html
Answer optiond
Marks: 2
What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws Exception
1032 {
URL obj = new URL("https://www.sanfoundry.com/javamcq");
URLConnection obj1 = obj.openConnection();
int len = obj1.getContentLength();
System.out.print(len);
}
}
A. 127
B. -1
C. Compilation Error
D. Runtime Error
Answer optionb
Marks: 2
1033 Select correct general form of Mouse Entered method of Mouse Listener
A. void mouseEntered(mouseEvent me)
B. void MouseEntered(mouseEvent me)
C. void MouseEntered(MouseEvent me)
D. void mouseEntered(MouseEvent me)
Answer optiond
Marks: 1
Consider following code segment-
1. public void mouseClicked(MouseEvent event){
2. setBackground(Color.blue);Â
3.int x = event.getX();Â
1034 4.int y = event.getY();Â
5.int c = getClickCount( );
6. }
Which statement is true?
A. There are syntax errors on line no. 1
B. There are syntax errors on line no. 2
C. There are syntax errors on line no . 4
D. There are syntax errors on line no. 5
Answer optiond
Marks: 1
Consider following code segment-
1. public void mouseClicked(MouseEvent event){
1035 2. boolean d = event.isPopupTrigger( );
3. }
In above code segment Line no. 2 specifies:
A. tests if this event causes a pop-up menu to appear on this platform.
B. tests if this event response pop-up menu to appear on this platform.
C. tests if this event is pop-up window.
D. tests if this event is pop-up Trigger.
Answer optiona
Marks: 1
Find the Error in given code for implementing Mouse motion event handl
import java.awt.*;
import java.awt.event.*;
public class MouseEventsDemo extends Frame implements KeyListener
{
String msg=""
int mouseX=0, mouseY=0;
public MouseEventsDemo() {
addMouseMotionListener(this);
addWindowListener(new MyWindowAdapter());
}
public void mouseDragged(MouseEvent me)
{
mouseX=me.getX();
mouseY=me.getY();
1036 msg= "* " + "mouse at " + mouseX + " , " + mo
repaint();
}
public void mouseMoved(MouseEvent me)
{
msg="Moving mouse at " + me.getX() + " , " + me.getY();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg, mouseX, mouseY);
}
public static void main(String [] args)
{
MouseEventsDemo M1= new MouseEventsDemo();
M1.setSize(new Dimension(300,300));
M1.setTitle("MouseEventsDemo");
M1.setVisible(true);
}
}
class MyWindowAdapter extends WindowAdapter
{
Public void windowClosing(WindowEvent we)
{
System.exit(0);
}
A. Error in registering Listener
B. All methods of Interface are not implemented
C. Implements Wrong name of interface class
D. Required packages are not implemented.
Answer optionc
Marks: 2
Consider following code segment-
public void mousePressed(MouseEvent event) {
1037 System.out.println(event.getPoint());
}
Following code segement output is-
A. Print value of x and y co-ordinates
B. Print value of x co-ordinates
C. Print value of y co-ordinates
D. Print value of event object.
Answer optiona
Marks: 1
Find the Error in given code for implementing Mouse motion event handl
import java.awt.*;
import java.awt.event.*;
public class MouseEventsDemo extends Frame implements MouseMotionListe
{
String msg=" "
int mouseX=0, mouseY=0;
public MouseEventsDemo() {
addMouseMotionListener(this);
addWindowListener(new MyWindowAdapter());
}
public void mouseMoved(MouseEvent me)
{
msg="Moving mouse at " + me.getX() + " , " + me.getY();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg, mouseX, mouseY);
1038 }
public static void main(String [] args)
{
MouseEventsDemo M1= new MouseEventsDemo();
M1.setSize(new Dimension(300,300));
M1.setTitle("MouseEventsDemo");
M1.setVisible(true);
}
}
class MyWindowAdapter extends WindowAdapter
{
Public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}
A. Error in registering Listener
B. All methods of Interface are not implemented
C. Correct Interface class not implemented
D. Required packages are not implemented.
Answer optionb
Marks: 2
Find the Error in given code for implementing Mouse motion event handl
import java.awt.*;
import java.awt.event.*;
public class MouseEventsDemo extends Frame implements MouseMotionListe
{
String msg=""
int mouseX=0, mouseY=0;
public MouseEventsDemo() {
addWindowListener(new MyWindowAdapter());
}
public void mouseDragged(MouseEvent me)
{
mouseX=me.getX();
mouseY=me.getY();
msg= "* " + "mouse at " + mouseX + " , "+ mous
1039 repaint();
}
public void mouseMoved(MouseEvent me)
{
msg="Moving mouse at " + me.getX() + " , "+ me.getY();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg, mouseX, mouseY);
}
public static void main(String [] args)
{
MouseEventsDemo M1= new MouseEventsDemo();
M1.setSize(new Dimension(300,300));
M1.setTitle("MouseEventsDemo");
M1.setVisible(true);
}
}
class MyWindowAdapter extends WindowAdapter
{
Public void windowClosing(WindowEvent we)
{
System.exit(0);
}
A. Listener not registered
B. All methods of Interface are not implemented
C. Correct Interface class not implemented
D. Required packages are not implemented.
Answer optiona
Marks: 2
Consider following code segment-
1. public void mouseClicked(MouseEvent event) {
1040 2. // Line 2
3. }
Following code segment, identify statement to print co-ordinates -
A. int p = getLocationOnScreen( );
B. Point p = getLocationOnScreen( );
C. int x,y = getLocationOnScreen( );
D. None of above
Answer optionb
Marks: 2
Find the Error in given code for implementing Mouse motion event handl
import java.lang*;
import java.util.event.*;
public class MouseEventsDemo extends Frame implements MouseMotionListe
{
String msg=""
int mouseX=0, mouseY=0;
public MouseEventsDemo() {
addMouseMotionListener(this);
addWindowListener(new MyWindowAdapter());
}
public void mouseDragged(MouseEvent me)
{
mouseX=me.getX();
mouseY=me.getY();
msg= "*" + "mouse at " + mouseX + " , " + mou
repaint();
}
public void mouseMoved(MouseEvent me)
1041 {
msg="Moving mouse at " + me.getX() + ", " + me.getY();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg, mouseX, mouseY);
}
public static void main(String [] args)
{
MouseEventsDemo M1= new MouseEventsDemo();
M1.setSize(new Dimension(300,300));
M1.setTitle("MouseEventsDemo");
M1.setVisible(true);
}
}
class MyWindowAdapter extends WindowAdapter
{
Public void windowClosing(WindowEvent we)
{
System.exit(0);
}
A. Listener not registered
B. All methods of Interface are not implemented
C. Correct Interface class not implemented
D. Required packages are not imported
Answer optiond
Marks: 2
1042 Which constructor is used to set the grid layout with vertical gap and
A. GridLayout()
B. GridLayout(int rw, int cl)
C. GridLayout(int rw, int cl, int hgap, vgap)
D. All of the above
Answer optionc
Marks: 1
Write the correct code at blank spaces:
1043
import java.awt.*;
import java.awt.event.*;
public class MouseMotionListenerExample extends Frame implements Mouse
{
MouseMotionListenerExample()
{
addMouseMotionListener(this);
setSize(300,300);
setLayout(null);
setVisible(true);
}
public void ___________(MouseEvent e) {
Graphics g=getGraphics();
g.setColor(Color.RED);
g.drawOval(e.getX(),e.getY(),20,20);
}
public void _____________(MouseEvent e) {}
public static void main(String[] args) {
new MouseMotionListenerExample();
}
}
A. mouseDragged, mouseMoved
B. mousePressed,mouseDragged
C. mouseClicked,mouseMoved
D. mouseReleased,mouseClicked
Answer optiona
Marks: 2
Find error in given program
1. import java.awt.*;
2. import java.awt.event.*;
1044 3. public class KeyListenerExample extends Frame implements KeyLis
MyLAbel;
4. TextArea area;
5. KeyListenerExample(){
6. MyLabel=new Label();
7. MyLabel.setBounds(20,50,100,20);
8. area=new TextArea();
9. area.setBounds(20,80,300, 300);
10. add(MyLabel);add(area);
11. setSize(400,400);
12. setLayout(null);
13. setVisible(true);
14. }
15. public void keyPressed(KeyEvent e) {
16. MyLabel.setText("Key Pressed");
17. }
18. public void keyReleased(KeyEvent e) {
19. MyLabel.setText("Key Released");
20. }
21. public void keyTyped(KeyEvent e) {
22. MyLabel.setText("Key Typed");
23. }
24. public static void main(String[] args) {
25. new KeyListenerExample();
26. }
27. }
A. Listener not registered
B. All methods of Interface are not implemented
C. Wrong name of Interface class
D. Required packages are not imported
Answer optiona
Marks: 2
1045 The ______________ method changes the location of the event.
A. int getX( )
B. Point getPoint( )
C. translatePoint( )
D. isPopupTrigger( )
Answer optionc
Marks: 1
Find error in given program
1 import java.awt.*;
2 import java.awt.event.*;
3 public class KeyListenerExample extends Frame implements KeyLis
MyLAbel;
4 TextArea area;
5 KeyListenerExample(){
6 MyLabel=new Label();
7 MyLabel.setBounds(20,50,100,
8 area=new TextArea();
9 area.setBounds(20,80,300, 300
10 area.addKeyListener(this);
11 add(MyLabel);add(area);
12 setSize(400,400);
13 setLayout(null);
1046 14 setVisible(true);
15 }
16 public void keyPressed(KeyEvent e) {
17 MyLabe
Pressed");
18 }
19 public void keyReleased(KeyEvent e) {
20 MyL
Released");
21 }
22 public static void main(String[] args) {
23 ne
KeyListenerExample();
24 }
25 }
A. Listener not registered
B. All methods of Interface are not implemented
C. Wrong name of Interface class
D. Required packages are not imported
Answer optionb
Marks: 2
Find error in given program
import java.awt.*;
import java.awt.event.*;
public class KeyListenerExample extends Frame implements KeyBoardListe
{ Label MyLAbel;
TextArea area;
KeyListenerExample()
{
MyLabel=new Label();
MyLabel.setBounds(20,50,100,20);
area=new TextArea();
area.setBounds(20,80,300, 300);
area.addKeyListener(this);
add(MyLabel);add(area);
setSize(400,400);
setLayout(null);
1047 setVisible(true);
}
public void keyPressed(KeyEvent e)
{
MyLabel.setText("Key Pressed");
}
public void keyReleased(KeyEvent e)
{
MyLabel.setText("Key Released");
}
public void keyTyped(KeyEvent e)
{
l.setText("Key Typed");
}
public static void main(String[] args)
{
new KeyListenerExample();
}
}
A. Listener not registered
B. All methods of Interface are not implemented
C. Implements Wrong name of Interface class
D. Required packages are not imported
Answer optionc
Marks: 2
1048 ContentHandler , MulticastSocket , URL, SocketImpl are included in --
A. .net
B. .util
C. . io
D. .lang
Answer optiona
Marks: 1
1049 HttpURLConnection , URLConnection , URL are included in --------p
A. .net
B. .util
C. . io
D. .lang
Answer optiona
Marks: 1
Find error in given program
import java.util.*;
import java.util.event.*;
public class KeyListenerExample extends Frame implements KeyListener{
Label MyLAbel;
TextArea area;
KeyListenerExample()
{
MyLabel=new Label();
MyLabel.setBounds(20,50,100,20);
area=new TextArea();
area.setBounds(20,80,300, 300);
area.addKeyListener(this);
add(MyLabel);add(area);
setSize(400,400);
setLayout(null);
1050 setVisible(true);
}
public void keyPressed(KeyEvent e) {
MyLabel.setText("Key Pressed");
}
public void keyReleased(KeyEvent e) {
MyLabel.setText("Key Released");
}
public void keyTyped(KeyEvent e) {
l.setText("Key Typed");
}
public static void main(String[] args)
{
new KeyListenerExample();
}
}
A. Listener not registered
B. All methods of Interface are not implemented
C. Wrong name of Interface class
D. Required packages are not imported
Answer optiond
Marks: 2
Consider following code segment-
1. public void textValueChanged(TextEvent e) {
2. TextComponent tc = (TextComponent) e.getSource();
1051 3. // Line No. 3
4. }
Above segment of code, identify code a Line No 3 to display text in Te
A. System.out.println("Typed value in TextComponent "+tc.getText());
B. System.out.println("Typed value in TextComponent "+tc.paramString());
C. System.out.println("Typed value in TextComponent "+tc.getSource());
D. System.out.println("Typed value in TextComponent "+tc.getValue());
Answer optiona
Marks: 2
Consider following code segment-
1. t=new TextField(20);
1052 2. public void textValueChanged(TextEvent te) {
3. // Line No. 3
4. }
Above segment of code, identify the code at Line No 3 to set the frame
A. setTitle(t.getValue());
B. setTitle(te.getText());
C. setTitle(te.getValue());
D. setTitle(t.getText());
Answer optiond
Marks: 2
Consider following code segment-
1. TextArea typeText, displayText;
2. public void textValueChanged(TextEvent e) {
3.String str=typeText.getText();
1053 4.// Line No. 4
5.}
Following segment of code, identify code a Line No 4 to read text from
display to displayText
A. displayText.setText(e.str);
B. displayText.setText(e.getText());
C. displayText.setText(str);
D. displayText.setText(e.typeText);
Answer optionc
Marks: 2
Fill the blank at line no 5.
1. public class WindowExample extends Frame implements WindowListe
2. {
3. WindowExample()
4. {
1054 5. _______________ (this);
6. setSize(400,400);
7. setLayout(null);
8. setVisible(true);
9. }
A. addWindowListener
B. addwindow
C. WindowListener()
D. addwindowlistener
Answer optiona
Marks: 1
1055 -------------------- layout lays out the components in a directional f
A. Grid Layout
B. Card Layout
C. FlowLayout
D. BorderLayout
Answer optionc
Marks: 1
1056 Identify the incorrect Integer constants for WindowEvent.
A. WINDOW_ACTIVATED
B. WINDOW_DEACTIVATED
C. WINDOW_LOST_FOCUS
D. WINDOW_GOT_FOCUS
Answer optiond
Marks: 2
Write the correct code at blank space:
public class ____________ extends Frame implements WindowListener
{
WindowExample()
{
addWindowListener(this);
setSize(400,400);
1057 setLayout(null);
setVisible(true);
}
public static void main(String[] args) {
new WindowExample();
}
A. addWindowListener
B. WindowExample
C. Window
D. WindowListener
Answer optionb
Marks: 1
Which top-level class provides methods to add and remove keyboard and
1058 listeners-
A. Object
B. ActionEvent
C. EventObject
D. Component
Answer optiond
Marks: 1
1059 The getActionCommand( ) method returns-
A. String
B. Object
C. int
D. void
Answer optiona
Marks: 1
1060 --------------------- class displays a dialog window from which the us
file.
A. java.awt.FileDialog
B. java.awt.Dialog
C. java.awt.File
D. All of the above
Answer optiona
Marks: 1
1061 The getItem( ) method returns-
A. String
B. Object
C. void
D. int
Answer optionb
Marks: 1
1062 Which method used to capture ALT, CTRL, META OR SHIFT keys-
A. getWhen( )
B. getActionCommand( )
C. getModifiers( )
D. getAdjustable( )
Answer optionc
Marks: 1
1.public void textValueChanged(TextEvent e) {
2.TextComponent tc =Â (TextComponent)Â e.getSource();
1063 3.System.out.println("Typed value in TextComponent "Â + e.getText());
4. }
Following segment of code, Identify syntax error-
A. There are syntax errors on line no. 1
B. There are syntax errors on line no. 2
C. There are syntax errors on line no. 3
D. There are syntax errors on line no. 2 and 3
Answer optionc
Marks: 1
1.Label label;
2.TextField textField=new TextField();
3.public void keyPressed(KeyEvent ke) {
1064 4.// Line No 4
5. }
Identify code at Line No. 4 to get key code-
A. char keyChar=key.getKeyChar();
B. charkeyChar = textField.getKeyChar();
C. char keyChar=label.getKeyChar();
D. char keyChar = KeyEvent.getKeyChar();
Answer optiona
Marks: 1
1065 Select the interface which define a method actionPerformed()?
A. ComponentListener
B. ContainerListener
C. ActionListener
D. InputListener
Answer optionc
Marks: 1
1.Label label;
2.TextField textField=new TextField();
3.public void keyPressed(KeyEvent ke) {
1066 4.// Line No 4
5.}
Identify code at Line No. 4 to get key code-
A. char keyChar =KeyEvent. getKeyCode ();
B. char keyChar =textField. getKeyCode ();
C. char keyChar =label. getKeyCode ();
D. char keyChar =ke. getKeyCode ();
Answer optiond
Marks: 1
1067 The translatePoint( ) method-
A. changes the location of the event.
B. changes x co-ordinates of the event.
C. changes y co-ordinates of the event.
D. returns the translate co-ordinates.
Answer optiona
Marks: 1
1068 Select the method of MouseMotionListener Interface.
A. mouseDragged()
B. MouseMotionListener()
C. MouseClick()
D. MousePressed()
Answer optiona
Marks: 1
Select the interface:
1069 Which defines a method itemStateChanged()?
A. ItemState
B. ContainerListener
C. ActionListener
D. ItemListener
Answer optiond
Marks: 1
1070 How many method define in FocusListener interface
A. one
B. two
C. four
D. seven
Answer optionb
Marks: 1
1071 How many method define in ContainerListener interface.
A. seven
B. two
C. five
D. one
Answer optionb
Marks: 1
1072 ------types of exceptions are occurred in networking programming
A. UnknownHostException
B. MalformedURLExeption
C. Exception
D. All of the above
Answer optiond
Marks: 1
1073 .net,.util,.lang are examples of -------
A. package
B. class
C. Interface
D. Method
Answer optiona
Marks: 1
1074 .net,.util,.lang,.gov, from this -----is a domain
A. .net
B. .util
C. .lang
D. .gov
Answer optiond
Marks: 1
1075 From following which is package?
A. .com
B. .util
C. .gov
D. All of the above
Answer optionb
Marks: 1
Networking classes encapsulate the "socket" paradigm pioneered in the
1076 abbreviation of BSD?
A. Berkeley Software Distribution
B. Berkeley Socket Distribution
C. Berkeley System Distribution
D. None of the above
Answer optiona
Marks: 1
1077 Datagrams are ------------------ of information passed between machin
A. bundles
B. sets
C. none of A and B
D. Both A and B
Answer optiona
Marks: 1
1078 TCP/IP style of networking provides ------------------
A. serialized stream of packet data
B. predictable stream of data
C. reliable stream of data
D. All of the above
Answer optiond
Marks: 1
1079 TCP includes many complicated algorithms for dealing with-------
A. congestion control on crowded networks
B. pessimistic expectations about packet loss
C. inefficient way to transport data
D. All of the above
Answer optiond
Marks: 1
-------- constructor specifies only a buffer that will receive data a
1080 packet.
A. DatagramPacket(byte data[], int size)
B. DatagramPacket(byte data[], int offset, int size)
C. DatagramPacket(byte data[], int offset, int size , InetAddress ipAd
D. All of the above
Answer optiona
Marks: 1
1081 DatagramPacket has ----------- methods
A. int getPort()
B. byte[] getData()
C. int getLength()
D. All of the above
Answer optiond
Marks: 1
What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws MalformedURLExce
{
1082
URL obj = new URL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.getPort());
A. 1
B. 0
C. -1
D. garbage value
Answer optionc
Marks: 2
import java.net.*;
class networking {
public static void main(String[] args) throws Exception {
URL obj = new URL("http://www.oracle.com");
URLConnection obj1 = obj.openConnection();
1083
int len = obj1.getContentLength();
System.out.print(len);
A. 0
B. 127
C. compile time error
D. run time error
Answer optiona
Marks: 2
Which steps occur when establishing a TCP connection between two comp
1084 sockets?
The server instantiates a ServerSocket object, denoting which port num
A. is to occur on
The server invokes the accept() method of the ServerSocket class. This
B. a client connects to the server on the given port
After the server is waiting, a client instantiates a Socket object, sp
C. name and port number to connect to
D. All of the above
Answer optiond
Marks: 2
Which of these transfer protocol must be used so that URL can be acces
1085 URLConnection class object?
A. http
B. https
C. Any Protocol can be used
D. None of the mentioned
Answer optiona
Marks: 1
What is the output of following program?
import java.io.*;
1086 import java.net.*;
public class URLDemo {
public static void main(String[] args) {
try {
URL url=new URL("http://www.sanfoundry.com/java-mcq");
System.out.println("Protocol: "+url.getProtocol());
System.out.println("Host Name: "+url.getHost());
System.out.println("Port Number: "+url.getPort());
} catch(Exception e){System.out.println(e);}
}
}
A. Protocol: http
B. Host Name: www.sanfoundry.com
C. Port Number: -1
D. all above mentioned
Answer optiond
Marks: 2
What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws Exception
{
1087 URL obj = new URL("https://www.sanfoundry.com/javamcq");
URLConnection obj1 = obj.openConnection();
System.out.print(obj1.getLastModified);
}
}
Note: Host URL was last modified on june 18 tuesday 2018 .
A. july
B. 18-6-2013
C. Tue 18 Jun 2013
D. Tue Jun 18 2018
Answer optiond
Marks: 2
1088 In Uniform Resource Locator (URL), path is pathname of file where info
A. Stored
B. Located
C. to be transferred
D. Transferred
Answer optionb
Marks: 1
1089 The class ________is used for accessing the attributes of remote resou
A. URI
B. URLConnection
C. URL
D. URLLoader
Answer optionb
Marks: 1
1090 How many forms of constructors URL class have?
A. 1
B. 2
C. 3
D. 4
Answer optionc
Marks: 1
1091 How many forms of constructors URLConnection class have?
A. 1
B. 2
C. 3
D. none of the above
Answer optiond
Marks: 1
1092 openConnection() method present in which class?
A. URL
B. URLConnection
C. InetAddress
D. HTTPURLConnection
Answer optiona
Marks: 1
1093 getContentType() method present in which class?
A. URL
B. URLDecoder
C. URLConnection
D. none of the above
Answer optionc
Marks: 1
1094 getContentLength() method present in which class?
A. URL
B. URLConnection
C. URLDecoder
D. URLNotFoundException
Answer optionb
Marks: 1
1095 Which of these classes can be added to a Frame component ?
A. Component
B. Window
C. Button
D. Applet
Answer optionc
Marks: 1
1096 getDate() method present in which class?
A. URL
B. URLDecoder
C. URLConnection
D. All of the mentioned
Answer optionc
Marks: 1
1097 Which of the following method of Applet class execute only once ?
A. stop()
B. paint()
C. start()
D. init()
Answer optiond
Marks: 1
1098 getConnectionTimeout() method present in which class?
A. URL
B. URLDecoder
C. URLConnection
D. URLNotFoundException
Answer optionc
Marks: 1
1099 getProtocol() method present in which class?
A. URL
B. URLDecoder
C. URLConnection
D. none of the above
Answer optiona
Marks: 1
1100 ___________method of DatagramPacket is used to find the port number.
A. port()
B. GetPort()
C. getPort()
D. findPort()
Answer optionb
Marks: 1
1101 getInetAddress( ) method present in which class?
A. URL
B. Socket
C. ServerSocket
D. none of the above
Answer optionb
Marks: 1
1102 getLocalPort( )method present in which class?
A. Socket
B. URLDecoder
C. URLConnection
D. URLNotFoundException
Answer optiona
Marks: 1
1103 getQuery() method present in which class?
A. URL
B. URLDecoder
C. URLConnection
D. none of the above
Answer optiona
Marks: 2
1104 getRef() method present in which class?
A. URLNotFound
B. URLDecoder
C. URLConnection
D. URL
Answer optiond
Marks: 1
1105 getPath() method present in which class?
A. URL
B. URLDecoder
C. URLConnection
D. none of the above
Answer optiona
Marks: 1
1106 URLConnection class present in which package?
A. url
B. urlconnection
C. URL
D. .net
Answer optiond
Marks: 1
1107 getExpiration( ) method present in which class?
A. URL
B. URLDecoder
C. URLConnection
D. none of the above
Answer optionc
Marks: 1
1108 To create menus on the container which of the following classes are us
A. Menu
B. MenuBar
C. MenuItem
D. All of the above
Answer optiond
Marks: 1
1109 ---------------------method is used to add the menu items to menus.
A. add()
B. addComponent();
C. addMenuItem()
D. setItem()
Answer optiona
Marks: 1
1110 ----------------------method is used to add the menubar to the frame.
A. setMenu()
B. setMenuBar()
C. addMenuBar()
D. All of the above
Answer optionb
Marks: 1
Which of the following components allow multiple selections?
1111 A. Checkbox B.Radio buttons C.Choice D.List
A. A and B
B. B and C
C. C and D
D. A and D
Answer optiond
Marks: 1
1112 _____ is immediate super class of Menu class.
A. MenuBar
B. MenuItem
C. MenuComponent
D. Object
Answer optionb
Marks: 1
Which of the following creates a List with 5 visible items and multipl
1113 enabled?
A. new List(5,true)
B. new List(true,5)
C. new List(5,false)
D. new List(false,5)
Answer optiona
Marks: 1
Which of the following may a menu contain?
A) separator
1114 B) check box
C) menu item
D) panel
A. A and B
B. B and C
C. A and D
D. A and C
Answer optiond
Marks: 1
1115 How could you set the frame surface color to pink ?
A. s.setBackground(Color.pink);
B. s.setColor(PINK);
C. s.Background(pink);
D. s.color=Color.pink
Answer optiona
Marks: 1
1116 which of the following method is used to retrieve whether checkbox is
A. getState()
B. getLabel()
C. setState()
D. setLabel()
Answer optiona
Marks: 1
Which of the following statements are true?
A) A Dialog can have a MenuBar.
1117 B) Menu extends MenuItem
C) A MenuItem can be added to a Menu.
D) A Menu can be added to a Menu.
A. A and B
B. B and C
C. A and D
D. C and D
Answer optionb
Marks: 1
write output of following
import java.net.*;
class networking16 {
public static void main(String[] args) throws MalformedURLExce
1118 URL obj = new URL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.toExternalForm());
}
A. sanfoundry
B. sanfoundry.com
C. www.sanfoundry.com
D. http://www.sanfoundry.com/javamcq
Answer optiond
Marks: 2