0% found this document useful (0 votes)
21 views8 pages

Question Bank AJP-1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views8 pages

Question Bank AJP-1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Q To Fig Q Mar

Question Answer Edit Dele


No pic ure Type ks

Calling ServerSocket() constructor with port value 'zero' means


1 3 N U 1 use a port number that is automatically allocated. Edit Dele
.

2 TCP/IP reserves the ports for specific protocols 3 N R 1 lower 1024 Edit Dele

Which of these package contains classes and interfaces for networking?


3 3 N R 1 java.net Edit Dele

4 A ServerSocket can connect to clients. 3 N R 1 multiple Edit Dele

5 A set of rules that governs data communication. 3 N R 1 protocol Edit Dele

6 A socket identifies in network. 3 N R 1 a communication end point Edit Dele

7 A socket is combination of 3 N R 1 Both A and B Edit Dele

A socket is of a two-way communication link


8 3 N R 1 one end-point Edit Dele
between two programs running on two hosts in the network.

9 Access control does not deals with 3 N R 1 Authenication Edit Dele

A is responsible for determining whether code executing in the Java runtime


10 environment has permission to perform a security- sensitive operation. 3 N R 1 policy object Edit Dele

byte[] getData() method of DatagramPacket class returns


11 3 N R 1 Byte array of data contained in datagram Edit Dele

Class URL represents ,a


12 3 N R 1 Uniform Resource Locator Edit Dele
pointer to a "resource" on the World Wide Web

13 Communication using TCP protocol is and 3 N R 1 connection-oriented, concurrent Edit Dele


Connection oriented communication is possible using
14 3 N R 1 Socket and ServerSocket Edit Dele
classes of Java.

15 How many bits are in a single IPv4 address? 3 N R 1 32 Edit Dele

16 How many bytes are required to represent an IPv4 address? 3 N R 1 4 Edit Dele

In InetAddress class which method returns the host name of the IP Address?
17 3 N R 1 public String getHostName() Edit Dele

18 In the format for defining the URL what is the last part? 3 N R 1 File path Edit Dele
19 In the URL, http://www.osborne.com:80/index.htm, 80 represents 3 N R 1 Port number Edit Dele

20 In UDP send() and receive() methods belong to which class? 3 N R 1 DatagramSocket Edit Dele

The following program is written for import


java.net.*; import java.io.*; public class MyServer { public static void main(String[] args) {
ServerSocket s; Socket c; try { InetAddress i=InetAddress.getByName("COMP30");
System.out.println(i); s=new ServerSocket(8088); System.out.println("Server Started..");
c=s.accept(); // PrintStream ps=new PrintStream(c.getOutputStream()); BufferedReader
br=new BufferedReader(new InputStreamReader(System.in)); // BufferedReader br1 =
new BufferedReader(new InputStreamReader(c.getInputStream())); String l=""; boolean
flag=true; DataInputStream dis=new DataInputStream(c.getInputStream());
21 DataOutputStream dos=new DataOutputStream(c.getOutputStream()); while(flag) 3 N A 2 TCPIP server Edit Dele
{ dos.writeUTF("Server-> "+br.readLine()); System.out.println("Client->
"+dis.readUTF()); } c.close(); } catch (Exception e) { e.printStackTrace(); } } }

The following program will display import


java.net.*; public class MyNetwork { public static void main(String args[]) throws
22 UnknownHostException { InetAddress ip [] = 3 N A 2 All IP addresses of www.google.com Edit Dele
InetAddress.getAllByName("www.google.com"); for(int i=0;i<ip.length;i++)
{ System.out.println(ip[i].getHostAddress()); } } }
The server listens for a connection request from a client using the following statement:
23 3 N U 2 Socket s = serverSocket.accept() Edit Dele

The Socket class has how many constructors that a client uses to connect to a server:
24 3 N A 2 2 Edit Dele

25 The User Datagram Protocol (UDP) is 3 N U 2 All of them Edit Dele

The models an IP address,which can be used to find the


26 3 N U 2 InetAddress class Edit Dele
host name IP address of the client

The which contains a set of pre- written


27 3 N U 2 java.net package Edit Dele
networking routines

This program is written for side import java.net.*; import


java.io.*; public class MyClient { public static void main(String[] args) { Socket c1; try
{ InetAddress i=InetAddress.getByName("COMP30"); System.out.println(i); c1=new
Socket("localhost",8088); System.out.println("Client Started.."); // PrintStream ps=new
PrintStream(c.getOutputStream()); BufferedReader br=new BufferedReader(new
InputStreamReader(System.in)); // BufferedReader br1 = new BufferedReader(new
InputStreamReader(c.getInputStream())); String l=""; boolean flag=true; DataInputStream
dis=new DataInputStream(c1.getInputStream()); DataOutputStream dos=new
28 3 N U 2 client Edit Dele
DataOutputStream(c1.getOutputStream()); while(flag) { dos.writeUTF("Server->
"+br.readLine()); System.out.println("Client-> "+dis.readUTF()); } c1.close(); } catch
(Exception e) { e.printStackTrace(); } } }

To Get All addresses by name of a URL - "www.google.com" following command is used InetAddress[] addresses = InetAddress.getAllByName(&quot;www.google.com&quot;);
30 3 N U 2 Edit Dele

To access the URLConnection Class object which of the transfer protocol is used?
31 3 N U 2 http Edit Dele

To connect to a serevr running on the same machine with client, which of the following
32 3 N U 2 All of the above Edit Dele
can be used for hostname?

To create Socket "S" by IP address "127.0.0.1" and port number "12345" Identify the
command A) Socket s = new Socket("127.0.0.1", 12345); B) ServerSocket s = new
33 3 N U 2 A Edit Dele
Socket("127.0.0.1", 12345); C) Socket s = new Socket("localhost", 12345);

To create a server socket on the specified port with a maximum queue length of maxlength
34 3 N U 2 b and c Edit Dele
which of the following constructor use?

ServerSocket has a method called , which is a blocking call that


35 3 N U 2 accept() Edit Dele
will wait for a client to initiate communications,

Socket connection = server.accept( ); In the above statement, server is an object of


36 class and accept() method throws 3 N U 2 ServerSocket, IOException Edit Dele
exception.

37 TCP and UDPs 3 N A 2 protocol Edit Dele

38 TCP does not supports Multicasting and Broadcasting because: 3 N U 2 It is connection oriented protocol. Edit Dele
The URL connection classes are good enough for simple programs that want to connect to
39 server to fetch content. 3 N U 2 HTTP Edit Dele

The--------------------method in the InetAddress class returns the IP


40 3 N U 2 getHostAddress() Edit Dele
address.

The client request a connection to a server using the following statement.


41 3 N A 2 Socket s=new Socket(ServerName,port); Edit Dele

Ch No 5
Q To Fig Q Mar
Question Answer
o pic ure Type ks

1 A Java program cannot directly communicate with an ODBC driver because 4 N R 1 ODBC written in C language

2 A JDBC technology -based driver ("JDBC driver") makes it possible to do ? 4 N R 1 All mentioned above

3 Abbreviate the term DSN 4 N R 1 Data Source Name

4 An API can be created for 4 N RN 1 All of these

5 API stands for 4 N R 1 application program interface

API which controls access to the row result of a given Statement and holds data retrieved from a database after you
6 4 N R 1 java.sql.ResultSet
execute an SQL query using Statement objects.

7 Application Server used in ____________________ 4 N R 1 Three-Tier Mode

8 Backbone of JDBC Architecture is ________________ 4 N R 1 Driver Manager

9 boolean isLast() method defines _______ 4 N R 1 Determines whether the ResultSet c ursor points to the last row of the

10 Callable Staement used to -------- 4 N R 1 calling procedure

11 Callable statement object in JDBC is used to execute a call to 4 N R 1 stored procedure

12 CallableStatement is used to execute_________________ 4 N R 1 Stored Procedures

public static Connection getConnecti on(String url, String name, String p


13 Choose the correct syntax for getConnection() method 4 N R 1
SQLException

14 Class.forName("_____________________________________") 4 N R 1 sun.jdbc.odbc.JdbcOdbcDriver

15 class.forName() method throws 4 N R 1 ClassNotFoundException

16 Connection object can be initialized using the _______ method of the DriverManager Class. 4 N R 1 getConnection()

createStatement() method without any parameter is used to create a statement with


17 4 N R 1 a forward only and read only ResultS et
__________

18 Database meta data are retrieved through______________________. 4 N R 1 a PreparedStatement object

19 DELETE statement of an SQL is executed by____________________________. 4 N R 1 executeUpdate()

DriverManager.getConnection(_______ , ______ , ______) What are the two parameters that are included ?
20 4 N R 1 URL or machine name where server r uns, User ID, Password

21 How can you execute DML statements (i.e. insert, delete, update) in the database? 4 N R 1 By invoking the executeUpdate(...) method of a Statement object

By invoking the special getter methods on the ResultSet: getString(...), getInt(…)


22 How can you retrieve information from a ResultSet? 4 N R 1

23 How many JDBC driver types are available by sun Microsystem? 4 N R 1 Four

24 How many steps are used to connect any java application with the database using JDBC? 4 N R 1 5

25 How many transaction isolation levels are defined in java.sql.Connection interface 4 N R 1 5


If a PreparedStatement is a SQL SELECT statement, you execute the statement using
26 4 N R 1 PreparedStatement.executeQuery();
________.

If you need to use a stored procedure with output parameters, which of the following statement type should be used
27 4 N R 1 CallableStatement
to call the procedure?

28 In 2-tier architecture , the first tier is generally_________________________ 4 N R 1 GUI

29 In JDBC _________imports all java classes concerned with database connectivity. 4 N R 1 java.sql.*

30 In the following JDBC drivers which is known as partly java driver? 4 N R 1 Native-API driver

In the three tier model the middle tier of the services acts as a mediator between
31 4 N R 1 Java application and databases
________________________ and________________________________.

Consider the following code. Fill the proper method in the blank space . import java.sql.*; import java.io.*; public class
UpdateRecord2 { public static void main(String args[]) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:av"); Statement stmt=conn.createStatement();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter rollno:"); String
rno=br.readLine(); System.out.println("Enter name:"); String nm=br.readLine(); System.out.println("Enter percentage:");
32 String p=br.readLine(); stmt.------------------------("update stud set name='"+nm+"',per="+p+" where rno="+rno); 4 N A 2 executeUpdate()
System.out.println("Record Updated"); stmt.close(); conn.close(); br.close(); } catch(ClassNotFoundException ce){}

33. Statement interface is used for ________________________________ 4 N U 2 sending SQL queries to the database

34. Stored procedures have which of the following advantages? 4 N U 2 Data integrity improves as multiple applications access the same stored

35. Suggest corrections in the following program segment import java.sql.*; import sun.jdbc.odbc.*; class mydatabase
{ public static void main(String args[]) { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con =
DriverManager.getConnection(); Statement stmt=con.createStatement(); stmt.execute("create table contacts(name public static void main(String args[]) throws SQLException
varchar(30),mobile varchar(20))"); con.close(); System.out.println("table created..."); } } 4 N A 2
DriverManager.getConnection(&quot;jdbc:odbc:mydsn&quot;);

35. Suppose a prepared statement is created as follows: Statement preparedStatement = connection.prepareStatement("insert


into Student (firstName, mi, lastName)" + "values (?, ?, 4 N U 2 preparedStatement.setString(1, 'John');
?)"); To set a value John to the first parameter, use

36 .The CallableStatement interface extends____________________________________interface 4 N U 2 PreparedStatement

37. The following example to connect Java Application with access? import java.sql.*; class Test { public static void
main(String ar[]) { try { String url="jdbc:odbc:mydsn"; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
c=DriverManager.getConnection(url); Statement st=c.createStatement(); ResultSet rs=st.executeQuery("select * from
login"); while(rs.next()) { System.out.println(rs.getString(1)); } }catch(Exception ee){System.out.println(ee);} } } 4 N A 2 with DSN

38. The following step is for stmt.executeUpdate(sql); sql = "INSERT INTO Registration " + "VALUES(103, 'Sumit',
4 N A 2 Insert
'Mittal', 28)"; stmt.executeUpdate(sql);

39. the interface to the database is handle by 4 N U 2 APIS

40. The JDBC-ODBC bridge allows ---------------------- to be used as --------------------------- 4 N U 2 ODBC drivers,JDBC drivers

41. The __________ method can be used on a ___________ object to create its meta data object 4 N U 2 getMetaData(),ResultSet

42.The __________ package contains classes that help in connecting to a database, sending SQL statements to the database, and
processing the query result
4 N U 2 java.sql
43.The __________method sets the query parameters of the PreparedStatement Object. 4 N U 2 setString()

44. The __________object provides you with methods to access data from the table. 4 N U 2 ResultSet
Ch no 6
Q
Question To Fig Q Mar
No Answer Ed
pic ure Type ks
1 In which method of the servlet, connection is created?
5 N R 1 init() Ed
2 ..................... is the first phase of the servlet life cycle. 5 N R 1 Initialization Ed

3 4.Name the class that includes the getSession() method 5 N R 1 HttpSession Ed

4 A cookie contains 5 N R 1 State information of user like name, address Ed

5 A cookie is stored on and contains state information. 5 N R 1 client Ed

6 A Deployement descriptor describes 5 N R 1 web component settings Ed

7 A JSP is transformed into a 5 N R 1 Java servlet Ed

8 A JSP is translated to 5 N R 1 Servlet Ed

9 A JSP page consists of which tags? 5 N R 1 Both A &amp; B Ed

A JSP page uses the java.util.ArrayList class many times. Instead of referring the class by
its complete package name each time, we want to just use ArrayList. Which attribute of
10 5 N R 1 import Ed
page directive must be specified to achieve this.

11 A servlet is an instance of .
5 N R 1 the HttpServlet class Ed
A user types the URL http://www.msbte.com/result.php. Which HTTP request gets
12
generated? Select the one correct answer
5 N R 1 GET method Ed
A is a small piece of information that is persisted
13
between the multiple client requests.
5 N R 1 cookie Ed

Abbreviate the term MIME?


14 5 N R 1 Multipurpose internet Mail Extension Ed

15 Advantage of JSP over Servlet is 5 N R 1 JSP is web page scripting language and servlets are Java programs Ed

An image file representing a company's logo has to be uploaded to the


16 server. Which of the following HTTP methods can be used in this 5 N R 1 doPut() Ed
situation?

17 An object of Which is created by the web container at time of deploying 5 N R 1 ServletContext Ed


the project?

By default, how long does a cookie last?


18 5 N R 1 By default, a newly created cookie persists until the browser exits. Ed

19 By Default, How many variables are available in JSP programs? 5 N R 1 6 Ed

20 By default, Tomcat runs on port .


1. Choose the missing statement in the given method syntax public void
doGet(HttpServletRequest request, HttpServletResponse response)
throws ____________

IOException
2. In which file do we define a servlet mapping?
web.xml
3. In which folder we have to save java file for servlet?
Classes

4. In which technology, we mix our business logic with the presentation logic?

Servlet

You might also like