Question Bank AJP-1
Question Bank AJP-1
2 TCP/IP reserves the ports for specific protocols 3 N R 1 lower 1024 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 Socket class has how many constructors that a client uses to connect to a server:
24 3 N A 2 2 Edit Dele
To Get All addresses by name of a URL - "www.google.com" following command is used InetAddress[] addresses = InetAddress.getAllByName("www.google.com");
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?
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
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
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.
9 boolean isLast() method defines _______ 4 N R 1 Determines whether the ResultSet c ursor points to the last row of the
14 Class.forName("_____________________________________") 4 N R 1 sun.jdbc.odbc.JdbcOdbcDriver
16 Connection object can be initialized using the _______ method of the DriverManager Class. 4 N R 1 getConnection()
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
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
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?
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("jdbc:odbc:mydsn");
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);
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
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
15 Advantage of JSP over Servlet is 5 N R 1 JSP is web page scripting language and servlets are Java programs Ed
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