AJP Important Questions
AJP Important Questions
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
16) If port number is not specified in the URL, getPort() method returns _______
(a) 0 (b) 1 (c) -1 (d) Unknown Port.
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
(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
?
(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
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
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
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