1
1
Which of the following method will you call on Request Dispatcher object to send the control to
a servlet/JSP.
o forward()
o redirect()
o send()
o redirect()
2. Choose the different categories of GoF design patterns.
o Behavioural
o Structural
o Notional
o Emprical
o Creational
3.
o
o
o
o
4. <servlet>
<servlet-name>Servlet1</servlet-name>
<servlet-class>myPackage.myServlet</servlet-class>
</servlet>
With repect to above code segment which of the following statements are true?
o
o
o
o
5. A developer for the company web site has been told that users may turn off cookie support in
their browser. What must the developer do to ensure that these customers can still use the web
application?
o The developer can ignore this issue. Web containers are required to support automatic URL
rewriting when cookies are not supported.
o The developer must add the string id=<sessionid> to the end of every URL to ensure that the
conversation with the browser can continue.
o The developer must ensure that every URL is properly encoded using the appropriate URL
rewriting APIs.
o The developer must provide an alternate mechanism for managing sessions and abandon the
HttpSession mechanism entirely.
6. Which of the following element is used to specify useful information about an initailzation
parameter of a servlet in the deployment descriptor?
o param-description
o info
o init-param-info
o description
7. A JSP page needs to set the property of a given JavaBean to avlaue that is calculated with the JSP
page. Which of the following jsp:setProperty attributes must be used to perform this
initialization?
o value
o property
o name
o attribute
o id
8.
o
o
o
o
9. You need to identify the browser type from which client request is forwarded and perform
action before further processing takes place in business logic. which is the best way to achieve
this?
o Use composite view pattern
o Use multiple if-else conditions in your business logic
o Use business delegate pattern
o Use filter class(Intercepting filter pattern)
10. Given in a single JSP page:
<%@taglib prefix='java' uri="myTags"%>
<%@taglib prefix='JAVA' uri="moreTags"%>
Which of the following are true?
o
o
o
o
11.
o
o
o
o
12.
o
o
o
o
13.
o
o
o
o
Select correct EL codes to print the first element of an array named employeeArray.
${employeeArray["0"]}
${employeeArray.[0]}
${employeeArray[0]}
${employeeArray.["0"]}
14.
o
o
o
o
15. Servlet A receives a request that if forwards to servlet B within another web application in the
same web container. Servlet A needs to share data with servlet B and that data must not be
visible to other servlets in A's web application. In which object can the data that A shares with B
be stored?
o HttpSession
o ServletContext
o HttpSessionResponse
o HttpServletRequest
16. The XYZ company has decided to port their web application to a new J2EE 1,5 container. While
reviewing the application, a developer realizes that in multiple places within the current
application, nearly duplicate code exists that finds enterprise beans. Which pattern should be
used to eliminate this duplicate code?
o Transfer Object
o Business delegate
o front controller
o Service Locator
17.
o
o
o
o
o
18.
o
o
o
o
19.
o
o
o
o
20.
o
o
o
o
21.
o
o
o
o
Which of the following statements are true with regards to URL rewriting?
None of the listed options
Server sends a text file to the client machine for maintaining session
You encrypt the URL for security purposes
You manually append sessionid to URL
22. If no file name is specified in the URL, which tag is used to config default page for the web site in
web.xml?
o <welcome-list><welcome-file>default1.jsp<welcome-file><welcome-file>default2.jsp<welcomefile></welcome-list>
o <welcome><welcome-file>default1.jsp<welcome-file><welcome-file>default2.jsp<welcomefile></welcome>
o <welcome-file-list><welcome-file>default1.jsp<welcome-file><welcomefile>default2.jsp<welcome-file></welcome-file-list>
o <file-list><welcome-file>default1.jsp<welcome-file><welcome-file>default2.jsp<welcomefile></file-list>
23. Choose the servlet code fragment that gets a binary stream for writing an image or other binary
type to the HttpServletResponse?
o java.io.PrintWriter out= new PrintWriter(response.getWriter());
o ServletOutputStream out= response.getOutputStream();
o ServletOutputStream out= response.getBinaryStream();
o java.io.PrintWriter out= response.getWriter();
24. Front Controller is a presentation tier pattern. State True or false.
o True
o False
25.
o
o
o
o
26.
o
o
o
o
27. ________ is a runtime, cointainer-managed object that evalutes custom actions during the
execution of a JSP page.
o URI
o Tag library descriptor
o Tag library
o tag handler
28. user provided the value 31 in a textbox named "age".What will be the output of ${param.age ge
25}?
o 31
o 1
o 25
o True
29.
o
o
o
o
31. Attribute value stored in context memory( ServletContext object) is by default thread safe. State
true or false.
o true
o false
32. ____________ is a collection of actions that encapsulate some functionality to be used from
within a JSP page.
o Tag library descriptor
o URI
o Presentation
o Tag library
33. A serializable object for transfering data over the network is an example of which of the
following design pattern?
o Assembler
o Session Facade
o Transfer Object
o Network Object
34.
o
o
o
o
35.
o
o
o
o
36.
o
o
o
o
37.
o
o
o
o
38.
o
o
o
o
39. Init params are accessible in Servlet constructor. State True or false.
o true
o false
40.
o
o
o
o
41.
o
o
o
o
Which of the following HTTP method puts or replaces a document on the server?
PUT
GET
TRACE
POST
42.
o
o
o
o
o
43.
o
o
o
o
44.
o
o
o
o
5. Long l=100;
syso(l);
ans:error
6. i=12
j=13
k=++i-j--;
ans : 13,12,0
code ans:true
20. atm there are two users who have add on cards...how to
after another one completes his transac...
ans...thread synchronization
21. which is more secure comparing get and post? Ans: post
22. what part of trigger determines the number of times d trigger body is executed?
a)trigger type b) trigger timing c)trigger body d)trigger event ans:a
on orders,suppliers TO PUBLIC.
identify the errors in the oracle statement?
Q-1)
import javax.servlet.http.*;
public class SessionListener implements HttpSessionListener
{
line1--
line 2--
//line--4
//line--5
(3)you enable session tracking management for JSP pages if the client has disabled cookies
Answer :1
(Q--7) which of the following method is over- ridden
(1)JSPInit()
(2)JSPDestroy()
(3)_JSPService()
(4) none of these
Answer: 1 & 2 but not confirm
(Q--8) Which of the following correctly defines JSP technology ?
(1) JSP page is a text-based document that describes how to process a request to create a response.
(2) JSP page is a text-based document that describes how to process a to response create a request.
(3) JSP page is a xml-based document that describes how to process a request to create a response.
(4) JSP page is a xml-based document that describes how to process a to response create a request.
Answer:I am confused in option 1 & 2 plz check it
(Q--9)
Your web application requires the ability to load and remove web files
Which two HTTP methods are used to perform these actions? (Choose two.)
1. PUT
2. POST
3. DELETE
4. REMOVE
5. DESTROY
answer---1 & 3
(q--10) question on jsp tag <jsp:setProperty > set bean with bean name is employeeName & bean value
is 10
which is employeeId in int
Select Two:
(1) <jsp:setproperty name="employeeName " property="*"/>
(2) <jsp:setbean name="employeeName " property="employeeid" value =10/>
(3) <%beanobject.setEmployeeId(int id);%>
(4) <%beanobject.setEmployeeId(String id);%>
answer ---2 & 3
1. Syntax of <c:url>
2. Where library descriptor file stored?
a. META-INF/tlds
b. META-INF/
c. WEB-INF/
d. WEB-INF/tlds
1.do get method syntax ..? ans : do get (httpserveletrequest request, httpserveletresponse response)
2.request is the object of..?
Ans: httpserveletrequest
3. EL consider null values as zero..? ans: true //not sure
4.<%! a=6%>
<%b=3%>
<%a=5%>
//not sure
ServletConfig
Which EL code snippet will insert this context parameter into the footer?
<a href='mailto:${footerEmail}'>Contact me</a>
<a href='mailto:${initParam@footerEmail}'>Contact me</a>
<a href='mailto:${initParam.footerEmail}'>Contact me</a>
<a href='mailto:${contextParam@footerEmail}'>Contact me</a>
<a href='mailto:${contextParam.footerEmail}'>Contact me</a>
8. How to store java primitive types in session? longattribute
9. Select two optionto retrieve first value in request variable
request.getParameter(" .");
Request.getParameterValues("..")[0];
18.getStream() of HttpServletResponse is object of ServletInputstream/PrintWriter/etc
19.switch case for JSTL <c:when>
24. to start a servlet we need- listener
1.model1 seperates view and control:false
2.el implicit objects and jsp implicit objects are same-false
3.credit card-post
4.jsp expression is used to-print
5.business tier components-Business deligates,Transfer objects,Session facade
6.decouples-business delegate,business application
7.singleton-creational design pattern
8.xml,html-mvc
9.for loop <inti;i<3;i++>- the value of i is 3.
10.init param can be accesed inside the servelet constructor-false
11<%!..!>,<%@..@>-declaration syntax
13structure of http request- get/uri/http/1.1
java.util.SortedMap
java.util.TreeSet
java.util.Hashtable
None
2. Suppose that you would like to create an instance of a new Map that has
an iteration order that is the same as the iteration order of an existing
instance of a Map. Which concrete implementation of the Map interface
should be used for the new instance?
a.
b.
c.
d.
TreeMap
HashMap
LinkedHashMap
The answer depends on the implementation of the existing instance.
3. Which loop automatically iterates over the specified object and reads
values one-by-one ?
a.
b.
c.
d.
For
For Each
Iterator
ListIterator
For
For Each
Iterator
ListIterator
hasNext()
remove()
nextToken()
next()
hasMoreElements()
6. Which class does not override the equals() and hashCode() methods,
inheriting them directly from class Object?
a.
b.
c.
d.
java.lang.String
java.lang.Double
java.lang.StringBuffer
java.lang.Character
d. ListIterator
8. Which of the following can read elements by specifying the index using
the get() method
a.
b.
c.
d.
For
Iterator
For Each
ListIterator
Hash Table
Hash Map
Tree Map
None
12.Which map interface stores the values in sorted order according to key
a.
b.
c.
d.
Hash Map
Hash Table
Tree Map
None
13.Which collection class allows you to grow or shrink its size and provides
indexed access to its elements, but whose methods are not
synchronized?
a.
b.
c.
d.
java.util.HashSet
java.util.LinkedHashSet
java.util.List
java.util.ArrayList
Java.util.Map
Java.util.List
Java.util.HashTable
Java.util.Collection
15.Which interface provides the capability to store objects using a keyvalue pair?
a.
b.
c.
d.
java.util.Map
Java.util.Set
Java.util.List
Java.util.Collection
f[0] = 0
f[0] = 0.0
compile time error
run time error
import java.util.*;
class H
{
public static void main (String[] args)
{
Object x = new Vector().elements();
System.out.print((x instanceof Enumeration)+",");
System.out.print((x instanceof Iterator)+",");
System.out.print(x instanceof ListIterator);
}
}
a. Prints: false,false,false
b.Prints: false,false,true
c. Prints: false,true,false
d.Prints: true,false,false
21. What will be the output of the program?
public class Test
{
private static int[] x;
public static void main(String[] args)
{
System.out.println(x[0]);
}
}
a. 0
b.null
c. Compile Error
d.NullPointerException at runtime
b.java.util.Set
c.java.util.List
d.java.util.Collection
23. Which collection class allows you to associate its elements with key values,
and allows you to retrieve objects in FIFO (first-in, first-out) sequence?
a.java.util.ArrayList
c.java.util.HashMap
b.java.util.LinkedHashMap
d.java.util.TreeMap
b.float f = 1.0;
d.float f = 1.0d;
25.
/* Missing Statement ? */
public class foo
{
public static void main(String[]args)throws Exception
{
java.io.PrintWriter out = new java.io.PrintWriter();
new java.io.OutputStreamWriter(System.out,true);
out.println("Hello");
}
}
What line of code should replace the missing statement to make this program
compile?
a. No statement required.
b. import java.io.*;
c. include java.io.*;
d..import java.io.PrintWriter;
26. The Collection interface is the base interface for _____________
a. Set
b. List
c. ArrayList
d. Linked List
e. Map
27. The Map is the base interface for _____________.
a. TreeMap
b. HashMap
c. LinkedHashMap
d. ArrayList
e. LinkedList
28. Which of the following statements are true?
a. The Collection interface is the root interface for manipulating a collection
of objects.
b. The Collection interface provides the basic operations for adding and
removing elements in a collection.
c. The AbstractCollection class is a convenience class that provides partial
implementation for the Collection interface.
d. Some of the methods in the Collection interface cannot be implemented in
the concrete subclass. In this case, the method would throw
java.lang.UnsupportedOperationException, a subclass of RuntimeException.
e. All interfaces and classes in the Collections framework are declared using
generic type in JDK 1.5.
f.All the above
29. Which of the following data types does not implement the Collection
interface?
a. HashSet
b. TreeSet
c. ArrayList
d. LinkedList
e. Map
30. If two objects o1 and o2 are equal, what are the values for o1.equals(o2)
and o1.hashCode() == o2.hashCode()?
a. true true
b. true false
c. false true
d. false false
31.Given:
import java.util.*;
public class PQ {
public static void main(String[] args) {
PriorityQueue<String> pq = new PriorityQueue<String>();
pq.add(carrot);
pq.add(apple);
pq.add(banana);
System.out.println(pq.poll() +: + pq.peek());
}
}
What is the result?
A. apple:apple
B. carrot:apple
C. apple:banana
D. banana:apple
E. carrot:carrot
F. carrot:banana
32.Given:
import java.util.*;
public class WrappedString {
private String s;
public WrappedString(String s) { this.s = s; }
public static void main(String[] args) {
HashSet<Object> hs = new HashSet<Object>();
WrappedString ws1 = new WrappedString(aardvark);
WrappedString ws2 = new WrappedString(aardvark);
String s1 = new String(aardvark);
String s2 = new String(aardvark);
hs.add(ws1); hs.add(ws2); hs.add(s1); hs.add(s2);
System.out.println(hs.size()); } }
What is the result?
A. 0
B. 1
C. 2
D. 3
E. 4
F. Compilation fails.
G. An exception is thrown at runtime.
33.import java.util.*;
class KeyMaster {
public int i;
public KeyMaster(int i) { this.i = i; }
public boolean equals(Object o) { return i == ((KeyMaster)o).i; }
public int hashCode() { return i; }
}
public class MapIt {
}
}
What is the result?
A. Compilation fails.
B. aAaA aAa AAaa AaA
C. AAaa AaA aAa aAaA
D. AaA AAaa aAaA aAa
E. aAa AaA aAaA AAaa
F. An exception is thrown at runtime.
36.
Given:
11. public static void append(List list) { list.add(0042); }
12. public static void main(String[] args) {
13. List<Integer> intList = new ArrayList<Integer>();
14. append(intList);
15. System.out.println(intList.get(0));
16. }
What is the result?
A. 42
B. 0042
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 13.
E. Compilation fails because of an error in line 14.
38. Given:
public void addStrings(List list)
{
list.add(foo);
list.add(bar);
}
What must you change in this method to compile without warnings?
A. add this code after line 11:
list = (List<String>) list;
B. change lines 12 and 13 to:
list.add<String>(foo);
list.add<String>(bar);
C. change the method signature on line 11 to:
public void addStrings(List<? extends String> list) {
D. change the method signature on line 11 to:
public void addStrings(List<? super String> list) {
E. No changes are necessary. This method compiles without warnings.
39. Given:
import java.util.*;
public class Test {
public static void main(String[] args) {
List<String> strings = new ArrayList<String>();
// insert code here
}
}
Which four, inserted at line 5, will allow compilation to succeed?
(Choose four.)
A. String s = strings.get(0);
B. Iterator i1 = strings.iterator();
C. String[] array1 = strings.toArray();
D. Iterator<String> i2 = strings.iterator();
E. String[] array2 = strings.toArray(new String[1]);
F. Iterator<String> i3 = strings.iterator<String>();
40. Collection can be used to store primitive data
A. True
B. False
42. ArrayList can be traversed using (Select two options )
A. foreach
B. for loop
C. While loop
D. Indexes
43. select a valid syntax for creating a HashSet
A. Set setName=new Set();
B. HashSet hashSet = new HashSet();
C. Set setName = new HashSet();
D. Set setName = new Set[];
44. Which is not a HashSet method
A. boolean add(Object element)
B. Iterator<E> iterator()
C. int size()
D. Object[] toArray()
45. Which of the following is not an ArrayList method (select two)
A. void add(int index,Object element)
B. boolean addAll(int index,Collection c)
C. boolean add(int index,Object element)
D. void addAll(int index,Collection c)
46. Which is the valid syntax of for-each loop
A. for (Object o : collection)
System.out.println(o);
B. for (Object o..collection)
System.out.println(o);
C. for (Object o,collection)
System.out.println(o);
D. for (Object o;collection)
System.out.println(o);
47. You need to store elements in a collection that guarantees that no
duplicates are stored and all elements can be accessed in natural order.
Which interface provides that capability?
A. java.util.Map
B. java.util.Set
C. java.util.List
D. java.util.Collection
48. Which is not the sub-interface of
public interface Collection{}
A.
B.
C.
D.
BeanContext
BeanContextServices
AbstractSet
SortedSet
16- Many users accesssing lots of tables each using more than 100 lines of code.
What is the best option?
1.View
2.Index
3.Stored Procedure ans:2
18- try{
int i=10;
int j=i/0;
return;
}
catch()
{
Sop(welcome);
}
SOP(j);
What happens?
1.prints welcome
2.Runtime-error
3.Compilation error ans:3
a)get
b)post
c)the parameter is added in httprequest
d)the parameter along with submit is added to request
24- which creates container of webpage ans:1
i)DIV ii)Span
26- whether we have to specify datatype in java Script? Ans: not required
27- <p:data>
<%=new Date()%>
<p:data/> ans:c
What is the body of the custom tag?
a) Scriptless b)expression language c)JSP
28- Filters can generate auto-response : true/False? Ans:true
29-JDBC statements are included in which package? Ans:java.sql.*
30-Which reference object in jsp is used in Http servlet Response
a)session
b)context
c)request
d)response ans:d
31- how to import a package into JSP? Ans: a
a) < @ page import="java.util.*;>
4).
class simple{
public static void main(String args[])
{
int a[10];
System.in.read(a[1]);
}
}
a) Throwable
b) Error type
c) Exception type
d) All the above
9).
a) IOException
b) ReadException
c) FileNotFoundException
d) Exception
10)What java statement is used to completely abort the execution of a loop
a) Continue
b) goto
c) exit
d) break
interface i
{
void show();
void set();
void just();
}
class x implements i
{
public void set()
{}
public void just()
{}
}
what happens when above code is processed?
a) no output
b) runtime error
c) compilation error
d) none of the above
2)A static method can be accessed by
a) Another static method only
b) By static and instance methods
c) Global Java functions
d) Cannot be accessed at all
3).The following is not implemented in Java
a) Method overloading
b) Method overriding
c) Operator overloading
d) Ignore
5). __________ is the Root Class of all Exception classes
a) Exception
b) Error
c) Throws
d) Throwable
6)What is the modifier that for a method, so that only one thread can access it at a time, in a multithreading context
a) Final
b) Synchronized
c) Abstract
d) Static
7)To implement Runnable, a class needs to implement the method
a) run()
b) CreateThread()
c) main()
d) None of the above
8)To implement JDBC in your program, you must import
a) java.awt package
b) java.applet package
c) java.sql package
d) java.net package
9)Integer is a ______________
a) Keyword
b) Wrapper Class
c) Data Type
d) Constructor
10). Commit() and RollBack() are methods belonging to which of the following classes?
a) Driver
b) Connection
c) Statement
d) ResultSet
1)What keyword is used to prevent an object from being serialized?
A.private
B.volatile
C.protected
D.transient
E.None of the above.
2)Select the order of access modifiers from least restrictive to most restrictive.
A.public,private,protected, default
B.default,protected,private,public
C.public, default,protected,private
D.default,public,protected,private
E.public,protected, default,private
3).Which access modifier allows you to access method calls in libraries not created in Java?
A public
B. static
C. native
D. transient
E. volatile
7)A ______ is a part of JVM that loads all classes that are required for the execution of the java program.
a) JRE
b) bytecode loader
c) class verifier
d) classloader
8). Which one of the following interface is used to call a stored procedure from java
a) StoredCall
b) CallProcedure
c) CallableStatement
d) None of the above
9)From OO point of view which of the following is better for creating a thread
2.Jsp is for presentation logic and servlet for BO- both are true
15. 1.Tld is a xml with description of entire library and tags
2. didnt remember both are true
16. There should be atleast one element ans:<!Element elemen(elment-content+)>
17. Request object is implicit in- ans:HTTpServletRequest
18. HttpSession implicit object in jsp- ans: sessioin
19. where to declare a object to use in entire session-ans: session.setAttriubute()
20. how to remove a attribute-ans: removeAttribute(String name)
21. In Expression language, how get a parameter name userId: ans-${param.userId}
22. int i=10;
If(((i++)>12)&&(++i<15)){
s.o.p(i);
else s.o.p(i);
ans-11
23. Best practices for Collection- use addAll() for copying, use generic types
24. Return type of Iterators next() method is Object
25. Performing specific styles on set of page elements is done by-Div
26. scenario for updating customer phone,address- create a view
27. when updating view should reflect into original db automatically- trigger
28. What are filter attributes are-<init>,<filter-class>,<context>,<config>,<name>
29. how to call a stored procedure of oracle database by JDBC - ans: callable Statement
30. what are not attributes of meta tag- htt-equiv,value,name,content- ans: value
31. (Scenario) what exception raised when number divided by zero: ans: divide zero exception(none of
above)
32. Need of alt attribute in img tag- ans: if image is not displayed alt tag value will get displayed
34. which are synchronized- Hasttable,hashmap,arraylist,vector-ans: Hash table,vector
35. Pl/Sql ans: plsql block can be anonymous&named, plsql block have declare&begin&exception