0% found this document useful (0 votes)
50 views4 pages

AJP Important Questions

The document contains 34 multiple choice questions about Java application programming concepts including: - Question 1 asks about which class send() and receive() methods belong to for UDP. - Question 2's options relate to whether statements about JSP are true or false. - Question 3 asks about the correct syntax of a servlet init() method. The questions cover topics like servlets, JSP, UDP, JDBC, sockets, cookies and more. The questions are multiple choice with options for each question.

Uploaded by

mayjunejuly282
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)
50 views4 pages

AJP Important Questions

The document contains 34 multiple choice questions about Java application programming concepts including: - Question 1 asks about which class send() and receive() methods belong to for UDP. - Question 2's options relate to whether statements about JSP are true or false. - Question 3 asks about the correct syntax of a servlet init() method. The questions cover topics like servlets, JSP, UDP, JDBC, sockets, cookies and more. The questions are multiple choice with options for each question.

Uploaded by

mayjunejuly282
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/ 4

AJP Important Questions

1) In UDP, send() and receive() methods belong to which class?


(a) Datagram Server (b) DatagramSocket Datagram Client (d) ServerSocket
(c)

2) Which of the following is true?


1)JSP is a client side technology
2)We can’t do client side validation with JSP
3)JSP is dynamic scripting
(a) Only 1 is true (b) Only 2 is true (c) 2,3 are true (d) All are true.

3) Which of the following is correct syntax of init() method of servlet ?


(a) void init(ServletConfig sc) throws (b) void init(ServletConfig) throws ServletException
ServletException
(c) void init(ServletConfig sc) (d) void init(ServletConfig sc) throws IOException

4) Which of the following are true for JSP technology?


1. It is persistent
2. Platform independent
3. Browser excutes the code
(a) Both 1 and 2 above (b) Only 2 (c) Both 1 and 3 (d) All of the above.

5) What is the difference between servlets and applets?


1.Servlets executes on Servers, where as Applets executes on Browser
2.Servlets have no GUI, where as an Applet has GUI
3.Servlets creates static web pages, where as Applets creates dynamic web pages
4.Servlets can handle only a single request, where as Applet can handle multiple requests
(a) Only 4 is correct (b) 1,3 are correct (c) 1,2 are correct (d) All of the above.

6) What is the first part of URL address?


(a) Protocol (b) Port number (c Host name (d) Information present
)

7) What will be the output of following program?


public class DemoServlet extends HttpServlet { public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException { PrintWriter out =
response.getWriter(); out.println(""); out.println(""); out.println(""); out.println(""); out.println("
"); out.println("Welcome to the Servlet World"); out.println("
"); out.println("
"); } }
(a) Missing ; (b) Welcome to the (c Error (d) Exception
Servlet World )

8) Which method of URL class is used to create object of URLConnection?


(a) remote Object() (b) connect() (c) openConnection (d) create()

9) State true or false for the following statements in Java:


i) Java beans slow down software development process.
ii) Java servlets do not have built in multithreading feature.
(a) i-false,ii-false (b) i-true,ii-false (c) i-false,ii-true (d) i-true,ii-true
10) Which of these is a return type of getAddress method of DatagramPacket class?
(a) InetAddress (b) SocketAddress (c) ServerAddress (d) IPAddress

11) What should be the correction done in the following program to get correct output?
import java.sql.*; import java.io.*; class InsertDemo { public static void main(String args[]) { int c=0; try
{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String myURL="jdbc:odbc:college"; Connection
con=DriverManager.getConnection(myURL); Statement st=con.createStatement(); c=st.executeUpdate("insert
into emp values(1,4000)") if(c!=0) System.out.println("Record inserted"); else System.out.println("Record NOT
inserted"); con.close(); }catch(Exception e){} } }
(a) exception (b) missing } (c) missing ; (d) No correction
statement required

12) Which among the following is an InetAddress factory method?


(a) static InetAddress (b) String toString() (c) byte[] (d) Boolean
getLocalHost() getAddress() equals(Object obj)

13) ___________port number is reserved for Http protocol.


(a) 80 (b) 53 (c) 1025 (d) 88

14) Match the following:


a) Datagram Socket i) UDP connection
b) URL ii) provides necessary framework of debugging java programs
c) java.net iii) makes it possible to communicate over a network with java programs
d) sun.tools.debug iv) is a java object that represent WWW address
(a) d-i, a-iv, c-iii, b-ii (b) c-i, a-iv, b-iii, d-ii (c) a-i, b-iv, c-iii, d-ii (d) b-i, c-iv, d-iii, a-ii

15) Given Statement may throws which exception?


InetAddress address =InetAddress.getByName("www.xyz.com");
(a) UnkownPort (b) UnknownURL (c) UnknownURN (d) UnknownHostException

16) If port number is not specified in the URL, getPort() method returns _______
(a) 0 (b) 1 (c) -1 (d) Unknown Port.

17) DSN stands for _________________________.


(a) Data Server name (b) Datagram (c) Datagram (d) Data Source Name
Source Name Server Name

18) Choose the class name to be used instead of A_Class to get correct output.
import java.net.*; class Sample { public static void main(String[] args)throws UnknownHostException { try
{ A_Class address=A_Class.getByName("google.com");
System.out.println(address); }catch(UnknownHostException e) { System.out.println("Caught : "+e); } } }
(a) InetAdress (b) ServerAdress (c) SocketAddress (d) DatagramAddress

19) Connection con = DriverManager.getConnection(_______ , ______ , ______);


What are the three parameters that are included ?
(a) connection_name,username,password (b) URL, username, password
(c) connection_object,username,password (d) URL,driver_name,password

20) JDBC-ODBC bridge product provide _______ access via ____________.


(a) data, drivers (b) JDBC driver, (c) driver, data (d) ODBC driver, JDBC
ODBC drivers driver
21) Which class is used to designed to be a "listener" which waits for client to connect before doing anything.
(a) Socket (b) Datagram (c) ServerSocket (d) InetAddress

22) Observe the following figure and identify the type


of architecture.
Figure:-

(a) Three-Tier (b) Two-Tier (c) Type – 1 Driver (d) Type -3 driver

23) Which type of driver is very flexible and need not code installation on the client machine?
(a) Type 3-JDBC-Net (b) Type 1-JDBC- (c) Type 2-Native- (d) Type -4-Database-
Pure java ODBC bridge API driver Protocol driver

24) ___________ interface allows storing results of query?


(a) ResultDataSet (b) MetaData (c) ResultSet (d) DatabaseMetaData

25) Which among the following is a method of DatabaseMetaData class?


(a) getDatabaseProductName() (b) boolean execute (String SQL)
(c) Statement createStatement() (d) All of the above

26) Identify component at ‘?’

?
(a) Database libraries (b) ODBC driver (c) DBMS (d) Application server

27) Which of the following statement is true in case security consideration for JDBC?
A) Normal unsigned applets are generally untrustworthy.
B) Downloaded driver should be used for connection purpose only.
C) No automatic or implicit use of local credentials while connecting to remote database servers.
D) Untrusted applets should not be permitted to access to local database data.
(a) A,B,C are true (b) C,D are true (c) Only B is true (d) all of the above

28) Which of the following is correct sequence of steps regarding to establish the connection with database?
1. Creating connection
2. Closing connection
3. Executing queries
4. Creating statement
(a) 1,4,3,2 (b) 2,3,4,1 (c) 1,2,3,4 (d) 4,3,1,2

29) Identify the classes of SQL package :


(a) DriverManager (b) Time (c) Both (d) None
30) The method - "public DatabaseMetaData getMetaData()" - belongs to the Interface _____________________
(a) Connection (b) Statement (c) Servlet (d) ServletRequest
interface interface interface interface

31) The CallableStatement interface extends _____________________ interface


(a) Statement (b) GenericServlet (c) Cookie (d) PreparedStatement

32) A cookie is stored on __________ and contains state information.


(a) Client (b) Server (c) Both (d) None

33) Connection object can be initialized using the ............................ method of the Driver Manager class.
(a) getConnection() (b) start() (c) init() (d) none of the above

34) UDP Packets are known as ___________________


(a) Packets (b) Datagrams (c) Sockets (d) Hyperlinks

35) Which among the following is NOT a valid life cycle method of JSP?
(a) jspInit() (b) jspStop() (c) jspService() (d) jspDestroy

36) In which phase of JSP life cycle ,JSP page turns into servlet?
(a) JSP Execution (b) JSP Translation (c) JSP Cleanup (d) JSP Compilation

37) Find out correct syntax of service() method of servlet class


(a) void service() (b) void getService(Servletequest req,
ServletResponse res)
(c) void service(ServletRequest req, (d) void getService()
ServletResponse res)

38) ResultSetMetaData Interface Object created by ______________ method, of ____________ interface


(a) getMetaData(), ResultSetData (b) getMetaData(), ResultSet
(c) createMetaData, ResultSet (d) setMetaData(), ResultSetData

39) The client request a connection to a server using the following statement
(a) Socket s = serverSocket.accept(); (b) Socket s = openConnection();c
(c) Socket s = HttpURLConnection.open(8080); (d) Socket s=new Socket(ServerName,port);

40) Arrange the statements according to the five steps of life cycle of servlet:
A :Create Servlet instance
B :Call destroy() - once
C : Load servlet
D : Call init() - once
E : Call service() – repeatedly for each client request.
(a) C,A,D,E,B (b) A,C,D,B,E
(c) C,D,E,A,B (d) A,C,D,E,B

You might also like