1. Which option is the best practice for developing JDBC code? Choose the right option.
1. Use java.sql.PreparedStatement for repeated DML commands
2. Use cache of database connections from a connection pool
3. Use column names for accessing ResultSet instead of column index numbers to avoid invalid column index message
4. all above
2. Which method will return an object of CallableStatement? Choose the right option.
1. prepareCall()
2. getPrepareCall()
3. callableStatement()
4. getCallableStatement()
3. Which interface is used to know the metadata of a database table?
Choose the right option.
1. DatabaseMetaData
2. ResultSetMetaData
3. TableMetaData
4. MetaData
4. What is the exception raised by the following forName() method?
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
Choose the right option.
1. ClassNotFoundException
2. SQLException
3. IllegalArgumentException
4. IllegalParameterException
5. Choose the right option about the methods of ResultSet that will not throw any exceptions?
(where res is an object of ResultSet)
1. res.absolute(-5);
2. res.relative(-5);
3 res.absolute(5);
4. all above
6. Which HTML form method is more efficient and used often to call servlets executed in a Servlet container?
1. method=”get”
2. method=”post”
3. method=”service()”
4. method=”action()”
7. Observe the code and choose the right option?
import javax.servlet.*; import java.io.*;
public class Test extends GenericServlet implements SingleThreadModel
{
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException
{
PrintWriter out = res.getWriter();
out.println("Sir");
}
}
1. The code compiles successfully without any deprecation warning
2. The code compiles successfully but with deprecation warning
3. Code does not compile
4. The message Sir will not go to client as MIME type is not set and out is not closed
8. Observe the code and choose the right option.
import javax.servlet.*; import javax.servlet.http.*; import java.io.*;
public class Test extends HttpServlet
{
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException
{
PrintWriter out = res.getWriter();
out.println("Sir");
out.close();
}
}
1. Code compiles and executes successfully.
2. does not compile as ServletRequest and ServletResponse are passed as parameters instead of HttpServletRequest and HttpServletResponse.
3. compiles with exceptions
4. none of above
9.
a) HTML snippet of code with two submit buttons
b) Servlet snippet of code
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
String str1 = req.getParameter("add" );
String str2 = req.getParameter("list");
}
When the user clicks “Add Cookie” button, what will be the value of str2 ?
1. List Cookies
2. Add Cookie
3. null
4. Empty string value
10. Observe the code and choose the right option.
// all necessary imports here
public class Demo extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
doPost(req,res);
}
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException,
IOException
{
// business logic
}
}
1. does not compile
2. compiles but throws exception
3. no problem in the code, successfully compiles and executes
4. none above
11. Which is not the Cookie method? Choose the right option.
1. getSecure()
2. getPath()
3. setPath()
4. setAge()
12. Choose the right option which will be true regarding URL Encoding.
1. URLs support only ASCII character set.
2. Any unsafe character outside the ASCII is to be converted to ASCII
3. 1 and 2
4. none above
13. web.xml do not have an entry for silverrate in
Choose all the right options that are true with the servlet.
import javax.servlet.*; import javax.servlet.http.*; import java.io.*;
public class Servlet1 extends HttpServlet
{
public void service(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
PrintWriter out = response.getWriter();
ServletContext context = getServletContext();
String str = context.getInitParameter("silverrate");
out.println(str);
out.close();
}
}
1. code compiles
2. output prints null
3. throws NullPointerException
4. 1, 2
14. Observe, in servlet code, both service() and doPost() methods are called. Choose the right option that is true about the code.
a) HTML code calling DemoServlet
b) Servlet code
import javax.servlet.*; import javax.servlet.http.*; import java.io.*;
public class DemoServlet extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
HttpSession session = request.getSession();
PrintWriter out = response.getWriter();
out.println("session is created in doPost() method");
}
public void service(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
HttpSession session = request.getSession();
PrintWriter out = response.getWriter();
out.println("session is created in service() method");
}
}
1. code does not compile
2. code compiles but throws exception at runtime
3. output will be “session is created in doPost() method”
4. output will be ” session is created in service() method ”
15. Choose the right option for the return type to fill up the blank.
————- xyz = session.getCreationTime(); // where session is an object of HttpSession
1. int
2. long
3. Calendar
4. Date
16. Choose the right URL encoding option for the following statement.
$ is 75
1. %24%20is%2075
2. %20%24is%2475
3. %22%40is%4075
4. %24%10is%1075
17. Which interface the implicit object “application” belongs?
1. ServletConfig
2. ServletContext
3. HttpServlet
4. HttpSession
18. Which is NOT part of function JSTL tags? Choose the right option.
1. fn.excapeXML()
2. fn.lowerCase()
3. fn.upperCase()
4. 2 and 3
19. Choose the right option of output for the following query string
city=Hyderabad&country=India?
${param.city}
${param.capital}
${param.country}
${paramValues.country[0]}
1. Hyderabad India
2. Hyderabad India India
3. Hyderabad null India
4. Hyderabad null India India
20. Which one of the following options is of right JSP syntax to fill up the blank?
<body>
————————————– // fill up the blank
News over.
</body>
1. <%@ include file=”news.html” %>
2. <jsp:include page=”Footer.jsp” />
3. <jsp:include file=”Footer.jsp” />
4. 1 and 2
21. Choose the right option that starts a background process.
1. $ls ch*.doc &
2. $ls ch*.doc *
3. $ls ch*.doc @
4. $ls ch*.doc %
22. Choose the best option that is true.
1. A process becomes a zombie when it exits, but its parent doesn’t call wait.
2. A process becomes an orphan when it’s still running, but its parent exits.
3. 1, 2
4. none above
23. The ‘ps’ Unix command displays the fields ———————————.
Choose the best option.
1. PID
2. TTY
3. CMD
4. all above
24. ‘pstree’ Unix command ——————————————. Choose the right option that is true.
1. displays the output in a tree diagram
2. will not display the output in a tree diagram
3. ‘pstree’ is not a Unix command
4. none above
25. Choose the best option that is true regarding the following grep Unix command.
grep hello$ /etc/passwd
1. displays all the lines that end with hello word
2. displays all the lines that start with hello word
3. does not display the lines that contains the word hello
4. none of above
26. Choose the best option that is true regarding the following tr Unix command.
tr ‘{ }”( )’ Demo.txt
1. converts all braces to parenthesis
2. converts all parenthesis to braces
3. command contains errors
4. none above
27. Choose the best option that is true regarding the following egrep Unix command.
egrep ‘^[k-r]’ Demo.txt
1. searches for the lines starting with letters k to r in the file Demo.txt
2. searches for the lines starting with letters k to r or K to R in the file Demo.txt
3. command contains errors
4. none above
28. Choose the best option that is true regarding the following uniq Unix command.
uniq -c Demo.txt
1. displays the number of times each letter is repeated in the file Demo.txt
2. displays the number of times each line is repeated in the file Demo.txt
3. displays the number of lines (line count) in the file Demo.txt
4. none above
29. Choose the best option that is true regarding the following paste command.
paste -s -d “|” abc.txt def.txt
1. merges the files sequentially
2. the delimiter is | (pipe)
3. 1 and 2
4. none above
30. Choose the option that is FALSE.
1. Number of elements in nested table is unbounded
2. Nested table subscript can be string or integer
3. Nested table starts as dense and can become sparse
4. Nested table is created in either in PL/SQL block or at schema level
31. Choose the right option for the blank in the following collection code to compile successfully.
DECLARE
TYPE marks IS TABLE OF NUMBER INDEX BY VARCHAR2(20);
student marks;
BEGIN
student('rao') := 55;
student('yadav') := 65;
student('reddy') := 75;
dbms_output.put_line(-----------------); -- blank here
END;
Fill up the blank of how to get total number of elements of this associative array.
1. student.LENGTH()
2. student.LENGTH
3. student.SIZE
4. student.COUNT
32. Choose the right option for the blank in the following Varray code that compiles successfully.
DECLARE
type student_names IS ------------------ OF ---------------- ;
names student_names;
total integer;
BEGIN
names := student_names('S N Rao', 'Jyothi', 'Jyostna');
total := names.count;
dbms_output.put_line('Total '|| total || ' Students');
END;
1. VARCHAR2(20) and VARRAY(20)
2. VARRAY(20) and VARCHAR2(20)
3. VARRAY(20) and VARRAY(20)
4. VARCHAR2(20) and VARCHAR2(20)
33. Choose the right option for the loop blank that prints all the records of Employee.
DECLARE
TYPE record_info IS RECORD
(
empname Employee.empname%TYPE,
empsal Employee.empsal%TYPE
);
TYPE table_info IS TABLE OF record_info;
all_employees table_info;
BEGIN
SELECT empname, empsal BULK COLLECT INTO all_employees FROM Employee;
for i in all_employees.first .. all_employees.last
---------------------------------------- -- LOOP blank
END;
1. LOOP dbms_output.put_line(all_employees(i).first || ‘ ‘ || all_employees(i).last); END LOOP;
2. LOOP dbms_output.put_line(all_employees(i).empname || ‘ ‘ || all_employees(i).empsal); END LOOP;
3. LOOP dbms_output.put_line(all_employees(i)[1] || ‘ ‘ || all_employees(i)[2]); END LOOP;
4. none above
34. Choose the right option that fits in the blank to iterate all through the records of Employee.
DECLARE
TYPE person_address_table IS TABLE OF Person.paddress%TYPE;
person_address person_address_table;
BEGIN
SELECT paddress BULK COLLECT INTO person_address FROM Person;
FORALL i IN 1 .. person_address.COUNT
UPDATE Person SET pname = 'ION' WHERE paddress = person_address(i);
FOR i IN 1 .. person_address.COUNT
LOOP DBMS_OUTPUT.PUT_LINE('Records updated = ' || ---------); -- blank here
END LOOP;
END;
1. SQL%BULK_ROWCOUNT(i)
2. SQL%BULK_ROWCOUNT[i]
3. SQL%BULK_ROWCOUNT
4. none of above
35. Choose the right option that fits in the blank to know the number of exceptions raised.
create table myTable1(z number not null );
declare
type mylist is table of number index by binary_integer;
------------------------------------ -- blank here
begin
yourlist(37) := null;
forall temp in 1 .. 50 save exceptions
insert into myTable1 values (yourlist(temp));
exception when others then
dbms_output.put_line('No. of Exceptions: ' || sql%bulk_exceptions.count);
end;
1. mylist yourlsit;
2. yourlist mylist;
3. yourlist binary_integer;
4. none above
36. Choose the right option that evaluates to FALSE from the following.
1. SQL is same for stand-alone LAN systems and internet-based network systems.
2. SQL benefits the application vendors to eliminate the need to develop their own database management software.
3. SQL based database systems are not portable across computer systems.
4. SQL is a computer language to manipulate the data stored in a relational database.
37. Which one of the options deletes the column cust_address from Customers in Oracle.
1. alter table Customers delete column cust_address;
2. alter table Customers drop column cust_address;
3. alter table Customers delete ust_address;
4. alter table Customers drop cust_address;
38. Choose the right option for the following truncate statement in Oracle.
truncate table Employee where empsal > 3000;
1. all the records where empal is more than 3000 are truncated
2. no records are truncated
3. does not compile
4. none above
39. Choose the right option that is true for the following roles and privileges.
create role manager;
create role developer;
create role tester;
grant select, insert on Employee to manager;
grant manager to developer, tester;
1. granting privilege on table Employee to manager is with syntax error
2. granting privilege to developer and tester is with syntax error
3. no error in the code and developer and tester gets the privileges of select and insert
4. none of above
40. Choose the right option to use with ‘outer join’.
1. Tables with not null value columns.
2. Tables with only compatible data.
3. Tables with null value columns.
4. Tables with only incompatible data
SOLUTIONS
1. 4 | 2. 1 | 3. 2 | 4. 1 | 5. 4 |
6. 1 | 7. 2 | 8. 1 | 9. 3 | 10. 3 |
11. 4 | 12. 3 | 13. 4 | 14. 4 | 15. 2 |
16. 1 | 17. 2 | 18. 4 | 19. 2 | 20. 4 |
21. 1 | 22. 3 | 23. 4 | 24. 1 | 25. 1 |
26. 1 | 27. 1 | 28. 2 | 29. 3 | 30. 2 |
31. 4 | 32. 2 | 33. 2 | 34. 1 | 35. 2 |
36. 3 | 37. 2 | 38. 3 | 39. 3 | 40. 3 |