0% found this document useful (0 votes)
54 views11 pages

Ajp QB 24-25 Students

Uploaded by

sayyedanadil04
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)
54 views11 pages

Ajp QB 24-25 Students

Uploaded by

sayyedanadil04
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/ 11

AJP QUESTION BANK

1. Select the proper constructor of DatagramPacket

O DatagramPacket(byte data, int DatagramPacket(byte data[ ], int offset)


size)

O DatagramPacket(byte data[ ], DatagramPacket(byte data[ ], int offset,


InetAddress ipAddress, int int size, InetAddress ipAddress, int port)
port)

2. The --- method returns number of rows affected

O execute() executeUpdate()

O executeQuery() none of above

3. . Prepared Statement object in JDBC used to execute........... queries.

O Executable High level

O Parameterized Simple

4. what type of exception thrown by URL class

O UnknownHostException URLException

O HostNotFoundException MalformedURLException

5. executeQuery() method returns_____________________

O single row C Single Column

O B Database Table D ResultSet object

6. What is servlet?

O Servlets are small program Servlets are used for intranet


used for developing and programming
executing web applications.

O Servlets are small program Servlets are programs written in C and C+


used for database applications +

7. Select the proper output for given code

import java.net.*;
class URLDemo {
public static void main(String args[]) throws MalformedURLException {
URL hp = new URL(""http://www.osborne.com/downloads"");
System.out.println(""Protocol: "" + hp.getProtocol());
System.out.println(""Port: "" + hp.getPort());
System.out.println(""Host: "" + hp.getHost());
System.out.println(""File: "" + hp.getFile());
System.out.println(""Ext:"" + hp.toExternalForm());
}
}

a. http Protocol: http


-1 Port: -1
www.osborne.com Host: www.osborne.com
/downloads File: /downloads
//www.osborne.com/ Ext:http::www.osborne.com
downloads

Protocol: http Protocol: http


Port: -1 Port: 80
Host: www.osborne.com Host: www.osborne.com
File: /downloads File: /downloads
Ext:http:// Ext:http://www.osborne.com/downloads
www.osborne.com/downloads

import java.sql.*; import java.sql.*; con.createstatement();


con.createStatement(s st.executeUpdate(s)
)
import java.sql.*; import java.sql.*; con.createStatement();
con.CreateStatement() st.executeUpdate(s)
8. PreparedStatement interface
extends____________________ interface

O Connection Statement

O Driver ResultSet

9. 1) PrintWriter class belongs to ----package

O util io

O awt Net

10. Select the proper syntax of doGet() method

O void doGet(ServletRequest void doGet(HttpServletRequest


req,ServletResponse res)throws req,HttpServletResponse res)
IOException, ServletException

O void doGet(HttpServletRequest void doGet(HttpServletRequest req,


req,HttpServletResponse ServletResponse res)throws IOException,
res)throws IOException, ServletException
ServletException

11.

Choose the classes of javax.servlet package

O ServletConfig AND GenericServlet AND Servlet


ServletContext

O ServletException AND ServletRequest and ServletResponse


GenericServlet

12. URL stands for

O unified resource locator unique resource location

O uniform Resource Locator Unique Resource Locator

13. Select the syntax of getAllByName() defined by InetAddress class

O static InetAddress[ ] static InetAddress getAllByName(String


getAllByName(String hostName)throws UnknownHostException
hostName)

O static InetAddress[ ] void InetAddress[ ] getAllByName(String


getAllByName(String hostName)throws UnknownHostException
hostName)throws
UnknownHostException

14. Connection is ------

O interface package

O class method

15. openConnection()method return---------


O URLConnection object InetAddress object

O void none of the above

16. Select the missing statement

O request.getParameter("data"); req.getParameter("data"); PrintWriter pw =


PrintWriter pw = res.getWriter();
response.getWriter()

O request.getParameter(); request.getParameter("data"); PrintWriter pw


PrintWriter pw = = request.getWriter();
response.getData();
17.

O line-8,9,10 are correct lint-8 wrong ,line 9-correct,line-10-wrong


statements

O line 8-is wrong, line 9 and 10 line 8,9,10 are wrong statement
correct

18 java servlets are efficient and powerful solution for creating


_______for web

O Dynamic content both a&b

O static content none

19 Which JDBC driver Type(s) can be used in either applet or servlet


code?

O Both Type 1 and Type 2 C. Both Type 3 and Type 4

O B. Both Type 1 and Type 3 D. Type 4 only

20. Select the incorrect option from the following

O Cookie HttpServlet

O HttpServletRequest HttpSessionBindingEvent
21 Select the proper constructor of URL class

O URL(String URL(String protocolName, String


protocolName, String hostName, String path)
hostName, intport,
String path)

O URL(String urlSpecifier) All of the above

22 What is default length of maxqueue in method throws


IOException ServerSocket(int port, int maxQueue,InetAddress localAddress) CO-4 U

O 100 65000

O 50 1024

23 Select the class available in java.sql package

O Connection DriverManager

O ResultSet Statement

24 what type of exception thrown by URL class

O UnknownHostException URLException

O HostNotFoundException MalformedURLException

25 Which of these methods of


DatagramPacket is used to obtain the byte array of
data contained in a datagram?

O getData() getArray()

O getBytes() recieveBytes()

26. Execution of delete SQL query in


JDBC, ............. method must be used.

O executeQuery() executeDelete()

O executeUpdate() executeDeleteQuery()

27 choose the classes of javax.servlet. package

O GenericServlet Cookie

O HttpServlet ServletContext
28. Identify correct syntax of service() method
of servlet interface

O void service(ServletRequest void service(ServletRequestreq,


req, ServletResponse res) ServletRequestreq )

O B)void service(ServletResponse D)void service(ServletResponsereq,


res ServletRequestreq, ) ServletResponse res)

29. Select the proper constructor of serverSocket class

O ServerSocket(int port, int ServerSocket(int port)


maxQueue,InetAddress
localAddress)

O ServerSocket(int port, int All of the above


maxQueue)

30. Select type-2 driver -----

O JDBC-ODBC Bridge driver JDBC-Net-Pure-Java driver

O Native API Partly-Java driver Native protocol Pure java driver

31. insert the correct statements in the


given program
O A) setContentType() and setContentType(“text/html”) and String
String p1=req.getparameter("t1");
p1=res.getParameter("t1");

O B) setContentType(“text/html”)) and String


p1=req.getParameter();
setContentType(“text/html”))
and String
p1=req.getParameter(“t1”);

32 Select the syntax of executeQuery()


method of Statement interface

O ) ResultSet executeQuery() ResultSetInterface executeQuery(String str)

O B) ResultSet D)boolean executeQuery(String str)


executeQuery(String str)

33 getWriter() method can be called by --------------------object (CO-6 R)

O ServletResponse object ServletConfig object

O ServletRequest object none of the above

34 select the proper method to add cookie

O void addCookie(Cookie int addCookie()


cookie)
O String addCookie(Cookie String addCookie(String cookie
cookie)
35 which method is used to return the IPAddress of local machine

O static InetAddress static InetAddress getHost( )


getLocalHost( )

O static InetAddress static InetAddress getByName( )


getHostName( )

36.
Which class implements a connectionless packet delivery service.

O ServerSocket InetAddress

O DatagramSocket DatagramPacket

37 Choose the classes of javax.servlet package

O ServletConfig AND GenericServlet AND Servlet


ServletContext
O ServletException AND ServletRequest and ServletResponse
GenericServlet

38 Insert the correct statement in program

O PrintWriter printwrite pw=res.getwriter()


pw=res.getWriter();

O printWriter printwriter p=req.getwriter()


pw=req.getWriter();

39 Select the various interfaces in import javax.servlet.*

O ServletRequest ServletConfig

O ServletResponse All of above

40 Select correct statement to delete


row from table employee where emp_id=555

41 java _______specification defined application programming


interface for communication between web server and application
program

Server Program
Servlet JDBC

42 which of these is return type of getAddress()method of


datagrampacket class

DatagramPacket InetAddress

DataGramSocket ServerSocket

43 getSession(true) method with true as its parameter will return


appropriate session object when

session completed session exists

session does not exists session object passed to another


method

44 Select the proper statement to establish the connection with


database

Connection Statement st=


con=DriverManager.getConnecti DriverManager.getConnection();
on(""Jdbc.odbc : DSN Name"");

Connection Connection
con=DriverManager.getConnecti con=DriverManager.getconnecti
on(); on("Jdbc.odbc : DSN Name");

45 Which of the following is an approach for state maintenance in web


application

Http session URL Writing

cookies all of the above

46 What is the limit of data to be passed from html when do get


method is used?

8KB 2KB

4KB 1KB

47 which class is used to create udp client

Socket DatagramPacket

DatagramSocket serverSocket

48 What is the function of method int getPort()

return the local port to which both a&b


socket object is connected

return the remote port to which NONE


socket object is connected

49 port no of email is---


25 23

21 79

50 Select correct statement to delete row from table employee where


emp_id=?

String sql=”delete from table String sql=”delete from table


where where
emp_id=?”;PreparedStatement emp_id=?”;PreparedStatement
st=con.prepareStatement(sql);st st=con.prepareStatement(sql);st
.executeUpdate(); .executeupdate()

String sql=”delete from table String sql=”delete from table


where where
emp_id=?”;PreparedStatement emp_id=?”;PreparedStatement
st=con.prepareStatement();st.ex st=con.prepareStatement(sql);st
ecuteUpdate(sql); .executeStatement();

You might also like