You are on page 1of 238

QUESTION 1

---------------------------------------------------------------------ResultSet is Updatable by default(true or false)


A) true
B) false
---------------------------------------------------------------------QUESTION 2
---------------------------------------------------------------------What is an actor model?
A) An actor model can represent an external entity which communicates with the system
B) An actor can represent a specific physical entity
C) An Actor model can represent a role played by the User.
D) All of the above
---------------------------------------------------------------------QUESTION 3
---------------------------------------------------------------------Which isolation level prevents dirty read in JDBC, connection class.
A) TRANSACTION_READ_UNCOMMITTED
B) TRANSACTION_READ_ COMMITTED
C) TRANSACTION_SERIALIZABLE
D) TRANSACTION_REPEATABLE_READ
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 4
---------------------------------------------------------------------Given:
1. import java.util.*
2. public class WrappedString {

3. private String s
4. public WrappedString(String s) { this.s = s }
5. public static void main(String[] args) {
6. HashSet hs = new HashSet ()
7. WrappedString ws1 = new WrappedString("aardvark" )
8. WrappedString ws2 = new WrappedString("aardvark" )
9. String s1 = new String("aardvark" )
10. String s2 = new String("aardvark" )
11. hs.add(ws1) hs.add(ws2) hs.add(s1) hs.add(s 2)
12. System.out.println(hs.size()) } } What is the result?

A) 1
B) 2
C) 3
D) 4
---------------------------------------------------------------------QUESTION 5
---------------------------------------------------------------------1 ..* can be defined as_____________
A) No limit on the number of instances (including none).
B) Zero or one instance. The notation.
C) Exactly one instance
D) At least one instance
---------------------------------------------------------------------QUESTION 6
---------------------------------------------------------------------A bean with a property color is loaded using the following statement
< jsp:usebean id="fruit" class="Fruit"/ >
What happens when the following statement is executed. Select the one correct answer.
< jsp:setProperty name="fruit" property="*"/ >
A)This is incorrect syntax of <jsp:setProperty/> and will generate a compilation error. Either value
or param must be defined.
B)All the properties of the fruit bean are initialized to a value of null.

C)All the properties of the fruit bean are assigned the values of input parameters of the JSP page
that have the same name.
D)All the properties of the fruit bean are initialized to a value of *.
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 7
---------------------------------------------------------------------A JSP file that uses a tag library must declare the tag library first. The tag library is defined using
the taglib directive <%@= taglib uri="..." prefix="..."%>
Which of the following specifies the correct purpose of prefix attribute. Select the one correct
answer.
1. The prefix defines the name of the tag that may be used for a tag library.
2. The prefix attribute defines the location of the tag library descriptor file.
3. The prefix attribute should refer to the short name attribute of the tag library file that is defined
by the uri attribute of taglib directive.
4. The prefix must be defined in the taglib directive and used in front of the tagname of a tag
A) 1
B) 2
C) 3
D) 4
---------------------------------------------------------------------QUESTION 8
---------------------------------------------------------------------A programmer has an algorithm that requires a java.util.List that provides an efficient
implementation of add(0, object), but does NOT need to support quick random access.
What supports these requirements?
A. java.util.Queue
B. java.util.ArrayList

C. java.util.LinearList
D. java.util.LinkedList
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 9
---------------------------------------------------------------------A team of programmer is involved in reviewing a proposed design for a new utility class. After
some discussion, they realize that the current design allows other classes to access methods in
the utility class that should be accessible only to methods within the utility class itself.
What design issue has the team discovered?
A) Tight Coupling
B) Low cohesion
C) Loose Coupling
D) Weak Encapsulation
---------------------------------------------------------------------QUESTION 10
---------------------------------------------------------------------A user types the URL http://www.manipalglobal.com/ibm/index.html . Which HTTP request gets
generated. Choose the correct answer

A) GET method
B) POST method
C) HEAD method
D) PUT method
---------------------------------------------------------------------QUESTION 11
---------------------------------------------------------------------All ____________ are notified of context initialization before any filter or servlet in the web
application is initialized.

A) ServletContextListeners
B) HttpSessionListener
C) ServletRequestListener
D) All of the above
---------------------------------------------------------------------QUESTION 12
---------------------------------------------------------------------Choose the correct one to import a entire package
A) import package
B) import package*;
C) import package.*;
D) import package.*.;
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 13
--------------------------------------------------------------------Choose
the incorrect option for Singleton pattern A) Provide a
default Private constructor.
B) Define a static Private object instance.
C) The client should be independent of how the products are created D)
Make the access method synchronized to prevent Thread problems.
E) Override the object clone method to prevent cloning.
A) A
B) B
C) C
D) D
E) E
----------------------------------------------------------------------

QUESTION 14
---------------------------------------------------------------------Choose the incorrect statement about SingleThreadModel.
A. It is used to ensure that servlet can handle only one request at a time.
B. It is a marker interface
C. It solves all the thread-safety issues
A) A
B) B
C) C
---------------------------------------------------------------------QUESTION 15
---------------------------------------------------------------------Choose the
invalid declaration of String array?

A) String[] s
B) String s[]
C) Stirng [s]
D) String []s
---------------------------------------------------------------------QUESTION 16
---------------------------------------------------------------------class
Animal { public String noise() { return "peep"; } } class
Dog extends Animal { public String noise() { return "bark";
}
}
class Cat extends Animal { public
String noise() { return "meow"; }
}
class Test{
public static void main(String[] args) {
Animal animal = new Dog();
Cat cat = (Cat)animal;
System.out.println(cat.noise());

}
}
What is the output of the above code?
A) peep
B) bark
C) meow
D) Compilation fails.
E) An exception is thrown at runtime
---------------------------------------------------------------------QUESTION 17
---------------------------------------------------------------------class Animal
{
String name = "animal";
String makeNoise() { return "generic noise"; }
}
class Dog extends Animal
{
String name = "dog";
String makeNoise() { return "bark"; }
}
public class Test
{ public static void main(String[]
args)
{
Animal an = new Dog();
System.out.println(an.name+" "+an.makeNoise());
}
}
A) animal generic noise
B) animal bark
C) dog bark
D) dog generic noise ---------------------------------------------------------------------QUESTION 18

---------------------------------------------------------------------class Base
{}

class Derived extends Base {


static void main(String args[]){
a = new Derived();

public
Base

System.out.println(a instanceof Derived);


}
}
A) true
B) false
---------------------------------------------------------------------QUESTION 19
---------------------------------------------------------------------class MyThread implements Runnable { public
void run(){
System.out.println("Running MyThread");
}
} // end of MyThread class
YourThread extends Thread { public
YourThread(Runnable r) { super(r);
}
public void run(){
System.out.println("Running YourThread");
}
} // end of YourThread
public class Test { public static void
main(String args[]) { MyThread t1 =
new MyThread();
YourThread t2 = new YourThread(t1);
t2.start();
}
}
What will be the ouput of the above Code?

A) Running MyThread
B) Running YourThread
C) Running MyThread
Running YourThread
D) Compilation fails
E) Runtime error
---------------------------------------------------------------------QUESTION 20
---------------------------------------------------------------------class SuperClass {
public int doIt(String str, Integer... data)throws ArrayIndexOutOfBoundsException{
String signature = "(String, Integer[])";
System.out.println(str + " " + signature); return
1;
}}
public class Test extends SuperClass{ public int
doIt(String str, Integer... data) throws Exception
{
String signature = "(String, Integer[])";
System.out.println("Overridden: " + str + " " + signature); return
0;
}
public static void main(String... args)
{
SuperClass sb = new Test();
try{
sb.doIt("hello", 3);
}catch(Exception e){
}
}
}
What is the output of the above code?
A) Overridden:hello(String,

Integer[])
B) hello (String, Integer[])
C) This code throws exception at run time
D) compile time error
E) B,D,E,F
---------------------------------------------------------------------QUESTION 21
---------------------------------------------------------------------Consider the below form in a HTML page. The Servlet has to add 1 marks to a variable 'marks', if
the student selects JAVA in the form. Which code below in the Servlets doPost() method will
achieve this?
< form method="post" action="Evaluate" >
<h2>Which language is Platform independent</h2>
<p><input type="radio" name="Q1" value="C"> C </input></p>
<p><input type="radio" name="Q1" value="C++"> C++ </input></p>
<p><input type="radio" name="Q1" value="JAVA"> JAVA </input></p>
<input type="submit" value="Submit">
< /form >
A) if(request.getAttribute("Q1").equals("JAVA")){marks+=1;
}
B) if(request.getParameter("Submit").equals("JAVA")){ marks+=1;
C) The form is wrong as you cannot give the same name "Q1" for all three radio buttons D)
if(request.getParameter("Q1").equals("JAVA")){ marks+=1;
}
---------------------------------------------------------------------QUESTION 22
---------------------------------------------------------------------Consider the code
int[] x = {5,6,7,8,9};
int[] y = x; y[2] =
10;
What is the value of x[2]?
A) 6

B) 7
C) 8
D) 10
E) 0
---------------------------------------------------------------------QUESTION 23
---------------------------------------------------------------------Design Pattern in which we separate abstraction and its implementation?
A) Decorator Pattern
B) Adapter Pattern
C) Bridge Pattern
D) Creational Pattern
---------------------------------------------------------------------QUESTION 24
---------------------------------------------------------------------Given that the current directory is empty, and that the user has read and write
permissions, and the following: 11 . import java.io.*;
12. public class DOS {
13. public static void main(String[] args) {
14. File dir = new File("dir");
15. dir.mkdir();
16. File f1 = new File(dir, "f1.txt");
17. try {
18. f1.createNewFile();
19. } catch (IOException e) { ; }
20. File newDir = new File("newDir");
21. dir.renameTo(newDir);
22. }
23. }
Which statement is true? A.
Compilation fails.
B. The file system has a new empty directory named dir.
C. The file system has a new empty directory named newDir.
D. The file system has a directory named dir, containing a file f1.txt.

E. The file system has a directory named newDir, containing a file f1.txt.
A) A
B) B
C) C
D) D E) E ---------------------------------------------------------------------QUESTION 25
---------------------------------------------------------------------Given the declaration
Circle x = new Circle(), which of the following statement is most accurate. A.
x contains an int value.
B. x contains an object of the Circle type.
C. x contains a reference to a Circle object.
D. You can assign an int value to x.
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 26
---------------------------------------------------------------------Given the following declarations, which of the assignments given in the options below would
compile. Select the two correct answers. int i = 5; boolean t = true; float f = 2.3F; double d = 2.3;

A. t = (boolean) i;
B. f = d;
C. d = i;
D. i = 5;
E. f = 2.8;
A) A,B,C
B) B,C
C) C,D
D) C,D,E
E) A,D,E

---------------------------------------------------------------------QUESTION 27
---------------------------------------------------------------------Given:
class Mammal { }
class
Raccoon extends Mammal {
Mammal m = new Mammal();
}
class BabyRaccoon extends Mammal { }
Which four statements are true? (Choose four.) A. Raccoon
is-a Mammal.
B. Raccoon has-a Mammal. C. BabyRaccoon is-a Mammal.
D. BabyRaccoon is-a Raccoon.
E. BabyRaccoon has-a Mammal.
F. BabyRaccoon is-a BabyRaccoon.
A) A,B,D,C
B) C,D,E,A
C) A,D,E,F
D) A,B,C,F
---------------------------------------------------------------------QUESTION 28
---------------------------------------------------------------------Given:
34. HashMap props = new HashMap();
35. props.put("key45", "some value");
36. props.put("key12", "some other value");
37. props.put("key39", "yet another value");
38. Set s = props.keySet();
39. // insert code here What, inserted at line 39, will sort the keys in the props
HashMap?
A. Arrays.sort(s);
B. s = new TreeSet(s);
C. Collections.sort(s);

D. s = new SortedSet(s);
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 29
---------------------------------------------------------------------Given: public interface A{public void m1();} class B
implements A{} class C implements A {public void
m1(){}} class D implements A{public void m1(int x){}}
abstract class E implements A{} abstract class F
implements A{public void m1(){}} abstract class G
implements A{public void m1(int x){}}
What is the result
A) compilation succeeds
B) Exactly one class does NOT compile
C) Exactly two classes do NOT compile
D) Exactly four classes do NOT compile
E) Exactly three classes do NOT compile
---------------------------------------------------------------------QUESTION 30
---------------------------------------------------------------------How is an abstract class represented in a class diagram?
A) Class Name is Underlined
B) Class Name is in Italics
C) Class Name is in Bold
D) Class Name is in uppercase
---------------------------------------------------------------------- QUESTION 31
---------------------------------------------------------------------How many numbers gets printed when the following JSTL code fragment is executed? Select the
one correct answer.

< %@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" % >


< c:set var="item" value="2"/ >
< c:choose >
< c:when test="${item greaterThan 0}" >
< c:out value="1"/ >
< /c:when >
< c:when test="${item==2}" >
< c:out value="2"/ >
< /c:when >
< c:otherwise >
< c:out value="4"/ >
< /c:otherwise >
< /c:choose >
A) No number gets printed.
B) 1
C) 2
D) 3
E) Error at the Ouput
---------------------------------------------------------------------QUESTION 32
---------------------------------------------------------------------How to represent an instance in a UML diagram
A) underline
B) slanted line
C) overline
D) Dashed line
---------------------------------------------------------------------QUESTION 33
---------------------------------------------------------------------If in test.jsp \${3+2-1}
: ${3+2-1} What is the
output?

A) ${3+2-1} : 4
B) \${3+2-1} : 4
C) \${4} : 4
D) ${4} : 4
---------------------------------------------------------------------QUESTION 34
-------------------------------------------------------------------import java.io.*; public class Test {
public static void
main(String[] args) {
String s1 = "abc";
String s2 = "def";
String s3 = s1.concat(s2.toUpperCase());
System.out.println(s1+s2+s3);
}
}
What is the output of the above code ?
A) abcDEF
B) abcdefabcdef
C) abcdefDEF
D) abcdefabcDEF
---------------------------------------------------------------------QUESTION 35
---------------------------------------------------------------------In a Sequence diagram, Slanted lines describe _____________
A) Construction of objects
B) Destruction of object
C) Propogation delay of messages
D) order of messages
E) race conditions
---------------------------------------------------------------------QUESTION 36

---------------------------------------------------------------------In Junit @Rule


TestName is invoked when ___________
A) to mark public fields of a test class
B) test is about to start
C) test method is running.
D) All of the above
---------------------------------------------------------------------QUESTION 37
---------------------------------------------------------------------In the Publish-Subscribe messaging model, the subscribers register themselves in a topic and are
notified when new messages arrive to the topic. Which pattern does most describe this model?

A) Adapter
B) Notifier
C) Observer
D) State
---------------------------------------------------------------------QUESTION 38
---------------------------------------------------------------------It is known as Action or Transaction and is used to encapsulate a request as an object to support
rollback, logging, or transaction functionality

A) Chain of Responsibility Pattern


B) Command Pattern
C) Observer Pattern
D) Strategy Pattern
---------------------------------------------------------------------QUESTION 39
---------------------------------------------------------------------Iterator Pattern is a type of _______________
A) Creational Patterns

B) Behavioral Patterns
C) Structural Patterns
---------------------------------------------------------------------QUESTION 40
---------------------------------------------------------------------Match the Following:
a. components : 1) Dashed Arrows
b. Dependencies : 2)rectangles with two tabs at the upper left. C
. Component : 3)Circle and solid line

A) a-3
b-1 c2
B) a2
b-1 c-3
C) a-1
b2 c-3
D) a-2
b-3 c1

---------------------------------------------------------------------QUESTION 41
---------------------------------------------------------------------Name the class that has getSession method, that is used to get the HttpSession object.
A) HttpServletRequest
B) HttpServletResponse
C) SessionContext
D) SessionConfig
---------------------------------------------------------------------QUESTION 42
---------------------------------------------------------------------Name the abstract class which consist of destroy and intializer methods
A) javax.servlet.http.HttpServlet
B) javax.servlet.GenericServlet
C) javax.servlet.http.HttpServletRequest

D) javax.servlet.http.HttpServletResponse
---------------------------------------------------------------------QUESTION 43
---------------------------------------------------------------------Pick runtime
exception?....
A. Class cast exception
B. File not found exception
C. Nullpointer exception
D. Security exception
E. Above all
A) A,B,C
B) C,D,E
C) A,D,E
D) A,C,D
E) E
---------------------------------------------------------------------QUESTION 44
--------------------------------------------------------------------public
class ArrayTest { int[] one; int[] two;
@Before
public void first(){one= new int[]{1,2}; two= new int[]{1,2};}
@Test public void test() {
assertArrayEquals(one, two);}
}
What is the result of executing the above JUnit Test?
A) Test fails as references of both the arrays are not equal
B) Test passes
C) Compilation fails as there is no method assertArrayEquals in Junit
D) Runtime exception occurs
---------------------------------------------------------------------QUESTION 45

---------------------------------------------------------------------public class
ByteTest {
public static void main(String[] args) {
String obj = "abc";
byte b[] =
obj.getBytes();
ByteArrayInputStream obj1 = new ByteArrayInputStream(b);
System.out.println((char)obj1.read());
}
What is the output?
A) a
B) b
C) c
D) abc
E) 97
---------------------------------------------------------------------QUESTION 46
-------------------------------------------------------------------public class Test { public static void main (String[] args)
{ new Test().go();
}
public void go() {
Runnable r = new Runnable() { public void run() { System.out.print("foo"); }
};
Thread t = new Thread(r);
t.start();
t.start(); } }
What is the result?
A) An exception is thrown at runtime.
B) Compilation fails.
C) The code executes normally and prints "foo".
D) The code executes normally, but nothing is printed.
---------------------------------------------------------------------QUESTION 47

--------------------------------------------------------------------public
class Test { public static void main(String args[]) {
try {
args.length;

int a =

int b = 10 / a;
System.out.print(a);
try {
== 1)
a - a;
{
c[] = {1};

if (a
a=a/
if (a == 2)
int
c[8]

= 9;
}
}
catch (ArrayIndexOutOfBoundsException e) {
System.out.println("TypeA");
}
}
catch (ArithmeticException e) {
System.out.println("TypeB");
}
}
}
A) TypeA
B) 0TypeA
C) 0TypeB
D) TypeB
---------------------------------------------------------------------QUESTION 48
-------------------------------------------------------------------public class Test { public static void main(String[]
args) { try{
System.out.println("String "+1/0);

}catch(ArithmeticException ae){
System.out.println("Catch block");
}
}
}
What is the output of the program?
A) String Infinity Catch block
B) String Catch block
C) Catch block
D) Infinity
---------------------------------------------------------------------QUESTION 49
---------------------------------------------------------------------public class
Test {
public static void main(String[] args) throws SQLException, ClassNotFoundException {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn =
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","HR","HR");
Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = st.executeQuery("SELECT * FROM survey");
rs.close();
st.close();
conn.close();
}}
Why do we use rs.absolute(5) in the above program?
A) Move cursor to the fifth-to-last row
B) Move cursor to the fifth row
C) Compilation fails
D) runtime error
---------------------------------------------------------------------QUESTION 50
---------------------------------------------------------------------public class
Test {

rs.absolute(5);

public static void main(String[] args) {


String a = "hello i love java";
System.out.println(a.indexOf('i')+" "+a.lastIndexOf('o')+" "+a.lastIndexOf('i')+" "+ a.indexOf('o'));
}
}
What is the ouput of the program?
A) 6 9 6 7
B) 6 9 6 4
C) 5 9 6 4
D) 5 9 5 4
---------------------------------------------------------------------QUESTION 51
---------------------------------------------------------------------public
Object m()
{
Object o = new Float(3.14F)
Object [] oa = new Object[l]/* Line 5 */
oa[0] = o /* Line 6 */ o = null /* Line
7*/ oa[0] = null /* Line 8 */ return o /* Line
9 */ }
When is the Float object, created in line 3, eligible for garbage collection?
A) just after line 5
B) just after line 6
C) just after line 7
D) just after line 8
E) just after line 9
---------------------------------------------------------------------QUESTION 52
---------------------------------------------------------------------Reaarrange the steps in a correct order to connect to the database?
A. Executing the ResultSet
B. Connecting to database
C. Executing the SQL Query

D. Registering the driver


A) C--->B--->D---->A
B) C--->A--->B---->A
C) D--->B--->C---->A
D) B--->D--->C---->A
---------------------------------------------------------------------QUESTION 53
---------------------------------------------------------------------Seperator used to segregate from the url and parameter values while calling the get() from the
html form?

A) *
B) #
C) ?
D) :
---------------------------------------------------------------------QUESTION 54
---------------------------------------------------------------------Steps for creating a Custom tag(Re-arrange)
A. Package Tag Handlers and TLD file into tag library
B. Write TLD file
C. Write Tag Handlers
D. Reference the TLD in the web-app deployment descriptor
A) A,B,D,C
B) D,C,B,A
C) B,C,A,D
D) A,C,D,B,
---------------------------------------------------------------------QUESTION 55
---------------------------------------------------------------------The ......................... method executes an SQL statement that may return multiple results.

A) executeUpdate()
B) executeQuery()
C) execute()
D) noexecute()
---------------------------------------------------------------------QUESTION 56
---------------------------------------------------------------------The life cycle of a servlet is managed by
A) JSP Engine
B) servlet container
C) WebServer
D) EJB Container
---------------------------------------------------------------------QUESTION 57
---------------------------------------------------------------------The performance of the application will be faster if you use PreparedStatement interface because
query is compiled only once?

A) true
B) false
---------------------------------------------------------------------QUESTION 58
---------------------------------------------------------------------The sendRedirect method defined in the HttpServlet class is equivalent to invoking the setStatus
method with the following parameter and a Location header in the URL. Select the one correct
answer.
A) SC_OK
B) SC_MOVED_TEMPORARILY
C) SC_NOT_FOUND
D) SC_INTERNAL_SERVER_ERROR
E) ESC_BAD_REQUEST
A) A

B) B
C) C
D) D E) E

---------------------------------------------------------------------QUESTION 59
---------------------------------------------------------------------This method is used to execute any SQL statement with a "SELECT" clause, that returns the
result of the query as a result set.
A. executeUpdate();
B. executeQuery();
C. execute();
A) A
B) B
C) C
---------------------------------------------------------------------QUESTION 60
---------------------------------------------------------------------To send binary output in a response, the following method of HttpServletResponse may be used
to get the appropriate Writer/Stream object. Select the one correct answer.

A) getStream
B) getOutputStream
C) getBinaryStream
D) getWriter
---------------------------------------------------------------------QUESTION 61
---------------------------------------------------------------------What is the output of the below code:
public class DemoServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
X x = new X();

HttpSession session = request.getSession();


session.setAttribute("Key", new X());
session.setAttribute("Key", x); session.setAttribute("Key",
"Hello"); session.removeAttribute("Key");
}
}
class X implements HttpSessionBindingListener{
@Override
public void valueBound(HttpSessionBindingEvent arg0) {
System.out.println("B");
}
@Override
public void valueUnbound(HttpSessionBindingEvent arg0) {
System.out.println("UB");
}
}
A) B B
UB
B) B
UB
UB
C) B
UB
D) B
B
UB
UB
---------------------------------------------------------------------QUESTION 62
---------------------------------------------------------------------public class JDBCDemo {
public static void main(String[] args) {
String sql = "select * from employee"; try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con =

DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","HR","HR");
Statement st = con.createStatement(); ResultSet
rs = st.executeQuery(sql); while(rs.next()){
System.out.println(rs.getInt(0));
}
}
catch(ClassNotFoundException |SQLException e){
System.out.println(e.getMessage());
}
}
}
A) null
B) No Data Found
C) Compilation fails
D) Invalid column index
---------------------------------------------------------------------QUESTION 63
---------------------------------------------------------------------What is the output of the below code:
interface A{
void method();
}
class Test{ public
void method(){
System.out.println("call from a method");
}
public static void main(String[] args) {
A a =(A) new Test(); a.method();
}
}
A) call from a method
B) No ouput at console
C) Compilation fails
D) Exception is thrown at Runtime

---------------------------------------------------------------------QUESTION 64
---------------------------------------------------------------------Given: import java.util.ArrayList; class Test{
public static void main(String[] args) {
ArrayList<String> m = new ArrayList<String>();
m.add("some string");//line3
m.add(54);//line4
m.add(new ArrayList<Integer>().add(70));//line5
m.add(new ArrayList<String>().add("some string"));//line6
}
}
A) Compilation fails at line3
B) Compilation fails at line4 C)
Compilation fails at line5
D) Compilation fails at line6
---------------------------------------------------------------------QUESTION 65
---------------------------------------------------------------------In multiple catch clause which of the following statements are valid?
A) Super class block will execute first
B) Sub class catch block will execute first
C) Super class catch block will never execute
D) Sub class catch block will never execute
---------------------------------------------------------------------QUESTION 66
---------------------------------------------------------------------What is the output of the below code: class
Test{
public static void main(String[] args) {
System.out.println(new Test(){ public
String toString(){ return

"test";
}
});
}
}
A) test
B) No output
C) Compilation fails
D) Exception is thrown at Runtime
---------------------------------------------------------------------QUESTION 67
---------------------------------------------------------------------import App; public class MyApp{ public static void
main(String[] args){
//code here;
}
}
How will you save the above java program?
A) App.java
B) App.class
C) MyApp.java
D) MyApp.class ---------------------------------------------------------------------QUESTION 68
---------------------------------------------------------------------- abstract
class MyClass{
abstract int m();
}
interface MyInterface{
public int m();
}
public class Test extends MyClass implements MyInterface{
//code to execute
}

Which of the following lines will allow the code to execute the program?
A) int m(){} int m(){}
B) int m(){} int
MyInterface.m(){} C) int
m(){}
D) None of the above
---------------------------------------------------------------------QUESTION 69
---------------------------------------------------------------------Which Exceptions should be replaced by ? for the code to compile?
class Test{ public static void main(String args[]) throws { try{
Class.forName("oracle.jdbc.OracleDriver");
Connection con = DriverManager.getConnection(
"jdbc:oracle:oci8:@/localhost:1521/XE", "hr", "hr");
}
catch(? e){ }
catch(? e){ }
}
}
A) ClassNotFoundException,SQLException
B) ClassCastException,SQL Exception
C) Exception,SQLException
D) ClassCastException,ClassNotFoundException
---------------------------------------------------------------------QUESTION 70
-------------------------------------------------------------------class Test{ public static void main(String[] args) { int
a=6,b=12; for(int i=0;i<3;i++){ a++;b--; if(a>b){
System.out.println("line of code");
}
else{
System.out.println("else block");
}

}
}
}
How many times "line of code" will execute ?
A) 0 times
B) 1 time
C) 2 times
D) 3 times
E) Compilation fails

QUESTION 1
---------------------------------------------------------------------What are the attribute names to be specified for the tag below
< %@ taglib __________="http://java.sun.com/jsp/jstl/core" _______="c" % >
A) url,uri
B) uri,suffix
C) uri,prefix
D) None of the above
---------------------------------------------------------------------QUESTION 2
---------------------------------------------------------------------What are the consequences of applying the abstract factory pattern?
A. it will be much easier to introduce new family of products
B. it makes it easier for a certain family of objects to work together
C. it makes it easier for the client to deal with tree-structured data
D. it makes the designed product families exchangeable
A) A,C
B) C,D
C) B,D
D) D,A
----------------------------------------------------------------------

QUESTION 3
---------------------------------------------------------------------What gets printed when the following code in a JSP is executed
< % int y = 0; % >
< % int z = 0; % >
< % for(int x=0;x<3;x++) { % >
< % z--;++y;% >
< % }% >
< % if(z<y) {% >
< %= z% >
< % } else {% >
< %= z - 1% >
< % }% >
A) 3
B) -1
C) 2
D) -3
E) generates compilation error
---------------------------------------------------------------------QUESTION 4
---------------------------------------------------------------------What gets printed when the following expression is evaluated? Select the one correct answer.
${"5" + "4"+6+8}

A) 5414
B) 5468
C) 23
D) 518
---------------------------------------------------------------------QUESTION 5
----------------------------------------------------------------------

What gets printed when the following expression is evaluated? Select the one correct answer.${12
% 4}

A) 0
B) 3
C) 8
D) 16
---------------------------------------------------------------------QUESTION 6
---------------------------------------------------------------------What gets printed when the following expression is evaluated? Select the one correct answer.${4
div 5} a. 0 b. 0.8
c. 1
d. -1
A) a
B) b
C) c
D) d
---------------------------------------------------------------------QUESTION 7
---------------------------------------------------------------------What gets printed when the following JSP code is invoked in a browser. Select the one correct
answer.
< %= if(Math.random() < 0.5) % > hello
< %= } else { % >
hi
< %= } % >
A) The browser will print either hello or hi based upon the return value of random.
B) The string hello will always get printed.
C) The string hi will always get printed.
D) The JSP file will not compile.

---------------------------------------------------------------------QUESTION 8
---------------------------------------------------------------------What gets printed when the following JSTL code fragment is executed? Select the one correct
answer.

< %@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" % >


< c:set var="item" value="2"/ >
< c:forEach var="item" begin="0" end="0" step="2" >
< c:out value="" default="abc"/ >
< /c:forEach >
A) The JSTL code does not compile as an attribute for forEach tag is not correct.
B) 0
C) 2
D) ABC
E) Nothing gets printed.
---------------------------------------------------------------------QUESTION 9
---------------------------------------------------------------------What happens if you call deleteRow() on a ResultSet object?
[A] The row you are positioned on is deleted from the ResultSet, but not from the database.
[B] The row you are positioned on is deleted from the ResultSet and from the database
[C] The result depends on whether the property synchronizeWithDataSource is set to true or false
[D] You will get a compile error: the method does not exist because you can not delete rows from
a ResultSet
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 10
---------------------------------------------------------------------What happens if you call the method close() on a ResultSet object?

[A] the method close() does not exist for a ResultSet. Only Connections can be closed.
[B] the database and JDBC resources are released
[C] you will get a SQLException, because only Statement objects can close ResultSets
[D] the ResultSet, together with the Statement which created it and the Connection from which the
Statement was retrieved, will be closed and release all database and JDBC resources
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 11
---------------------------------------------------------------------What is the ouput of the below code:
import java.io.*;
class files {
public static void main(String args[]) {
File obj = new File("/FilesDemo/DemoPrograms");
System.out.print(obj.getAbsolutePath());
}
}
A) FilesDemo/DemoPrograms
B) /FilesDemo/DemoPrograms/
C) /FilesDemo/DemoPrograms
D) Compilation fails
---------------------------------------------------------------------QUESTION 12
----------------------------------------------------------------------

What is the ouput of the below code:


class Test { public static void
main(String args[])
{
StringBuffer s1 = new StringBuffer("Hello");
StringBuffer s2 = s1.reverse();
System.out.println(s2);
}
}
A) Hello
B) olleH
C) Compilation fails
D) Runtime error
---------------------------------------------------------------------QUESTION 13
---------------------------------------------------------------------What is the ouput of the below code:class Test
{ public static void main(String[]
s)
{
String s1="Hello",s2="World";
System.out.println(s1+s2);
System.out.println(s1.concat(s2));
}
}
A) HelloWorld
B) HelloWorld
HelloWorld
C) Compilation fails
D) Runtime error
---------------------------------------------------------------------QUESTION 14
----------------------------------------------------------------------

What is the output for the below code ?


import java.util.LinkedList; import
java.util.Queue; public class Test { public
static void main(String... args) { Queue
q = new LinkedList();
q.add("newyork");
q.add("ca");
q.add("texas");
show(q);
}
public static void show(Queue q) {
Integer(11));
while

q.add(new

(!q.isEmpty ( ) )
System.out.print(q.poll() + " ");
}
}
A) newyork ca texas 11
B) ca newyork texas 11
C) 11 texas ca newyork
D) Compile error : Integer can't add
---------------------------------------------------------------------QUESTION 15
---------------------------------------------------------------------What is the output for the below code ?
public class Test {
public static void main(String argv[]){
ArrayList list = new ArrayList();
ArrayList listStr = list;
ArrayList listBuf = list;
listStr.add(0, "Hello");
StringBuffer buff = (StringBuffer) listBuf.get(0);;
System.out.println(buff.toString());
}}
A) Hello
B) Compile time error

C) java.lang.ClassCastException
D) null
---------------------------------------------------------------------QUESTION 16
---------------------------------------------------------------------What is the output for the below code ?
public interface TestInf {
int i =10;
} public class Test { public static void main(String...
args) {
TestInf.i=12;
System.out.println(TestInf.i);
}
}
A) 10
B) 12
C) compile time error
D) run time error
---------------------------------------------------------------------QUESTION 17
---------------------------------------------------------------------What is the output of below code,
File f = new File("c:\\test\\abc.txt");
System.out.println(f.getName());
A) abc
B) abc.txt
C) c:\test\abc.txt
D) compile error
---------------------------------------------------------------------QUESTION 18
---------------------------------------------------------------------What is the output of below code?

public class Bean{


private String str
Bean(String str ){ this.str
= str } public String
getStr() { return str
}
public boolean equals(Object o){
if (!(o instanceof Bean)) { return
false
} return ((Bean)
o).getStr().equals(str)
}
public int hashCode() {
return 12345
} public String toString()
{ return str
}
}
import java.util.HashSet public class
Test { public static void main(String
... sss) {
HashSet myMap = new HashSet()
String s1 = new String("das")
String s2 = new String("das")
Bean s3 = new Bean("abcdef") Bean
s4 = new Bean("abcdef")
myMap.add(s1) myMap.add(s2)
myMap.add(s3) myMap.add(s4)
System.out.println(myMap)
}
}
A) das abcdef
B) das abcdef das abcdef
C) das das abcdef abcdef
D) das

---------------------------------------------------------------------QUESTION 19
---------------------------------------------------------------------What is the output of the below code, public
class Test { public static void main(String[] args)
{ System.out.println("String "+new Integer("4")+5);
} }
A) String 9
B) String 45
C) compilation error
D) run time error
---------------------------------------------------------------------QUESTION 20
---------------------------------------------------------------------What is the output of the below code:
public class Test { public static void
main(String[] args) { big_loop: for (int
i = 0; i < 3; i++) { try {
< 3; j++) {

for (int j = 0; j

if (i==j) continue;

else if (i>j) continue big_loop;


System.out.print("A ");
} } finally
{
System.out.
print("B ");
}
System.out.print("C ");
}}}
A) A B C A B C A B C
B) A A B C A A A B C A A A B C
C) A A B B C A C A
D) A A B C B B
---------------------------------------------------------------------QUESTION 21

---------------------------------------------------------------------What is the output of the below code:


@WebServlet("/DemoServlet") public class DemoServlet extends HttpServlet { protected
void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {

doPost(request,response);

}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException { doGet(request,response);
}
}
A) No Output after execution
B) Infinite loop causing "StackOverFlowError"
C) Compilation error
D) None of the above
---------------------------------------------------------------------QUESTION 22
---------------------------------------------------------------------What is the output of the below code:
@WebServlet("/DemoServlet") public class DemoServlet extends HttpServlet { protected
void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
}
}
A) No Ouput after execution
B) Infinite Loop
C) Compilation error
D) Runtime error
---------------------------------------------------------------------QUESTION 23
----------------------------------------------------------------------

What is the output of the below code:


< %@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" % >
< c:forEach var="item" begin="0" end="9" step="2" >
${item}
< /c:forEach >
A) 1 2 3 4 5 6 7 8 9
B) 1 3 5 7 9
C) 0 2 4 6 8
D) 0 2 4 6 8 9
---------------------------------------------------------------------QUESTION 24
---------------------------------------------------------------------What is the output of the below code:
< %@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" % >
< c:set var="j" value="4,3,2,1"/ >
< c:forEach items="${j}" var="item" varStatus="status" >
< c:if test="${status.first}" >
< c:out value="${status.index}" default="abc"/ >
< /c:if >
< /c:forEach >
A) 0
B) 1
C) 2
D) 3
E) code does not compile
---------------------------------------------------------------------QUESTION 25
---------------------------------------------------------------------What is the output of the below code: class
Test { public static void main(String args[])
{
int array[] = new int [5];
for (int i =
5; i > 0; i--)
array[5 - i] = i;
Arrays.sort(array);

System.out.print(Arrays.binarySearch(array, 4));
}
}
A) 1
B) 1
C) 2
D) 3
---------------------------------------------------------------------QUESTION 26
---------------------------------------------------------------------What is the output of the below code:
class Test { public static void
main(String[] args) {
try {
Myclass object1 = new Myclass("Hello", -7, 2.1e10);
FileOutputStream fos = new FileOutputStream("serial");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(object1);

oos.flush();

oos.close();

}
catch(Exception e) {
System.out.println("Serialization" + e);
System.exit(0);
}
try
int x;

FileInputStream fis = new FileInputStream("serial");


ObjectInputStream ois = new ObjectInputStream(fis);
= ois.readInt();
ois.close();
System.out.println(x);
}
catch (Exception e) {
System.out.print("deserialization");
System.exit(0);
}
}

}
class Myclass implements Serializable {
String s;
int i;
double d;
Myclass(String s, int i, double d){
= d; this.i = i; this.s = s;

this.d

}
}
A) -7
B) Hello
C) Serialization
D) deserialization
---------------------------------------------------------------------QUESTION 27
---------------------------------------------------------------------What is the output of the below code:
class Test extends Thread{ public static
void main(String[] args) {
Test t = new Test();
t.setName("Thread 0");
t.start();
}
public void run(){
System.out.println(Thread.currentThread().getName());
}
}
A) Thread 0
B) main
Thread 0
C) Compilation error
D) Runtime error
----------------------------------------------------------------------

QUESTION 28
---------------------------------------------------------------------What is the output of the below code:
class Test{ public static void
main(String[] args) { new Thread(new
Runnable() {
@Override
public void run() {
System.out.println("Thread running");
}
}).start();
}
}
A) Thread running
B) No output
C) Compilation error
D) Runtime error ---------------------------------------------------------------------QUESTION 29
---------------------------------------------------------------------What is the output of the below code:
class Test{
public static void main(String[] args) {
Thread t = new Thread();
System.out.println(t.currentThread());
}
}
A) 1
B) 3
C) 5
D) 7
---------------------------------------------------------------------QUESTION 30
----------------------------------------------------------------------

What is the output of the below code:


import java.util.*;
class genericstack
<E> {
Stack <E> stk = new Stack
<E>(); public void push(E obj) {
stk.push(obj);
}
public E pop() {
E obj = stk.pop();

return

obj;
}
}
public class Test {

public static void main(String args[]) {

genericstack <String> gs1 = new genericstack<String>();


System.out.print(gs1.pop() + " ");
<Integer> gs2 = new genericstack<Integer>();

genericstack
gs2.push(36);

System.out.println(gs2.pop());
}
}
A) Hello
B) 36
C) compile time error
D) run time error
E) Hello 36
---------------------------------------------------------------------QUESTION 31
---------------------------------------------------------------------What is the output of the below code: public
class Test { public static void main(String[]
args){
System.out.println(Thread.currentThread().getName());
}
}
A) mainthread
B) Thread

gs1.push("Hello");

C) main
D) currentThread
---------------------------------------------------------------------QUESTION 32
---------------------------------------------------------------------What is the output of the below code: public
class Test { public static void main(String[]
args) { double x = 0, y
= 5.4324;
try {
System.out.println( (y/x) );
}
catch (Exception e) {
System.out.println("Exception");
}
catch (Throwable t) {
System.out.println("Error");
}}}
A) Exception
B) Error
C) Infinity

D) Exception Error
---------------------------------------------------------------------QUESTION 33
---------------------------------------------------------------------What is the output of the below code: public
class Test { public static void main(String...
args) { double d=2D+2d+2.+2l+2L+2f+2F+2.f+2.D;
System.out.println(d);
}
}
A) 18
B) 9
C) 9.0
D) 18.0
E) Run time exception
F) Compiler error
---------------------------------------------------------------------QUESTION 34
---------------------------------------------------------------------What is the output of the below code:
public class Test { public static void
main(String[] args) { List<String> list
= new ArrayList();
list.add("test");
list.add(123); list.add('c');
System.out.println(list);
}
}
A) [test,123,c]
B) No output
C) compilation fails
D) Runtime error
---------------------------------------------------------------------- QUESTION 35

What is the output of the below code?


class Test{
public static void main(String[] args) {
Object obj = new Object();
System.out.println(obj.getClass());
}
}
A) class java.lang.Test
B) class java.lang.Object
C) java.lang.Object
D) java.lang.Test
---------------------------------------------------------------------QUESTION 36
---------------------------------------------------------------------What is the output of the below code? public
class Test { public static void main(String[] args)
{ List<Integer> list = new
ArrayList<Integer>(); list.add(9); list.add(8); list.add(2);
list.add(5); list.add(1);
Iterator itr = list.iterator();
Collections.reverse(list);
Collections.sort(list); while(itr.hasNext()){
System.out.println(itr.next());
}
}
}
A) 9
8
2
5
1
B) 1 5
2

8
9
C) 1
2
5
8
9
D) 1
2
9
8
5
---------------------------------------------------------------------QUESTION 37
---------------------------------------------------------------------What is the sequence of method execution in Filter?
A)init,doFilter,destroy
B)doFilter,init,destroy
C)destroy,doFilter,init
D)destroy,doFilter
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 38
---------------------------------------------------------------------What will be the output of the below code: if(
"Welcome".trim() == "Welcome".trim() )
System.out.println("Equal"); else
System.out.println("Not Equal");
A) compile and display Equal
B) compile and display Not Equal

C) cause a compiler error


D) compile and display NULL
QUESTION 39
---------------------------------------------------------------------What will be the output of the program? class
MyThread extends Thread{
MyThread(){}
MyThread(Runnable r){
super();} public void run(){
System.out.println("Inside Thread");
}}
class MyRunnable implements Runnable{ public
void run(){
System.out.println("Inside Runnable");
}}
class Test{ public static void main(String[]
args){ new MyThread().start(); new
MyThread(new MyRunnable()).start();
}
}
A) Inside Thread
Inside Thread
B) Inside Thread
Inside Runnable
C) Does Not compile
D) Throw Exception at runtime
---------------------------------------------------------------------QUESTION 40
---------------------------------------------------------------------What will be the result of compiling and run the
following code: import java.io.File; public class Test
{
public static void main(String... args) throws Exception {

File myDir = new File("test");


// myDir.mkdir();
File myFile = new File(
myFile.createNewFile();

myDir, "test.txt");

}}
A) create directory "test" and a file name as "test.txt
B) java.io.IOException
C) Compile with error
D) None of the above
---------------------------------------------------------------------QUESTION 41
---------------------------------------------------------------------Whats is the output of the below code:
class Test extends Thread{ public
static void main(String[] args) { Vector
v = new Vector(3,2); v.add("data 1");
v.add("data 2");
v.add("data 3");
v.removeAll(v);
System.out.println(v.isEmpty());
}
}
A) true
B) false
C) comiplation fails
D) Runtime error
---------------------------------------------------------------------QUESTION 42
---------------------------------------------------------------------When using HTML forms which of the folowing is true for POST method? Select the one correct
answer.

A. POST allows users to bookmark URLs with parameters.

B. The POST method should not be used when large amount of data needs to be transferred.
C. POST allows secure data transmission over the http method.
D. POST method sends data in the body of the request.
A) A
B) B
C) C
D) D
QUESTION 43
---------------------------------------------------------------------When would you use the Singleton design pattern?
A. to limit the class instantiation to one object
B. to provide global access to one instance across the system
C. to ensure that a certain group of related objects are used together D. to abstract steps of
construction of complex objects

A) A
B) A,B
C) A,B,C
D) A,B,D
---------------------------------------------------------------------QUESTION 44
---------------------------------------------------------------------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
B) java.util.LinkedHashMap
C) java.util.HashMap
D) java.util.TreeMap
---------------------------------------------------------------------QUESTION 45
----------------------------------------------------------------------

Which Design Pattern provides a way to access the elements of an aggregate object sequentially
without exposing its underlying representation.
A) Iterator
B) Command
C) Observer
D) Strategy
---------------------------------------------------------------------QUESTION 46
---------------------------------------------------------------------Which design pattern you would you use to decouple the creation procedure of a complex object
from it's concrete instance to be able to apply that procedure on variety of implementations.

A) Factory builder design pattern


B) Method Builder design pattern
C) Builder design pattern
D) Factory method design pattern
---------------------------------------------------------------------QUESTION 47
---------------------------------------------------------------------Which design pattern you would you use to limit the class instantiation to one object?
A) Builder design pattern
B) Factory Method Design Pattern
C) Prototype design pattern
D) Singleton design pattern
---------------------------------------------------------------------QUESTION 48
---------------------------------------------------------------------Which Interface does not contain setAttribute() and getAttribute()?
A) ServletConfig
B) ServletContext
C) HttpRequest
D) HttpSession
---------------------------------------------------------------------QUESTION 49
---------------------------------------------------------------------Which is the object allows to access the sendRedirect()?
A) request
B) response
C) session
D) context
---------------------------------------------------------------------QUESTION 50

---------------------------------------------------------------------Which Is the suitable webcomponent to perform tasks like authentication, data compression,
logging and auditing?

A) Filter
B) Servlet
C) JSP
D) servlet container
---------------------------------------------------------------------QUESTION 51
---------------------------------------------------------------------Which Man class properly represents the relationship "Man has a best friend who is a Dog"?
A) class Man extends Dog { }
B) class Man implements Dog { }
C) class Man { private BestFriend dog; }
D) class Man { private Dog bestFriend; }
E) class Man { private Dog<bestFriend>; }
---------------------------------------------------------------------QUESTION 52
---------------------------------------------------------------------Which methods belong to Thread Class a.
wait()
b. run()
c. start()
d. notify
e. notifyAll()
f. interrupt()
A) a,b,d
B) c,d,e,f
C) b,c,f
D) b,d,e,f
----------------------------------------------------------------------

---------------------------------------------------------------------QUESTION 53
---------------------------------------------------------------------Which numbers gets printed when the following JSTL code fragment is executed? Select the
correct answer.

< %@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" % >


< c:set var="j" value="4,3,2,1"/ >
< c:forEach items="${j}" var="item" begin="1" end="2" varStatus="status" >
< c:out value="${status.count}" default="abc"/ >
< /c:forEach >
A. 1
B. 2
C. 3
D. 4
E. The program does not compile.
A) A,B
B) B,C
C) A,C
D) D,E
E) C,D,E
---------------------------------------------------------------------QUESTION 54
---------------------------------------------------------------------Which of the following are the session tracking techniques?
A. URL rewriting, using HttpSession object, using response object, using hidden fields
B. URL rewriting, using HttpSession object, using cookies, using hidden fields
C. URL rewriting, using servlet object, using response object, using cookies
D. URL rewriting, using request object, using response object, using session object
A) A
B) B
C) C

D) D
QUESTION 55
---------------------------------------------------------------------Which of the following interfaces has getWriter() method?
A) HttpServletRequest
B) HttpServletResponse
C) ServletRequest
D) ServletResponse
---------------------------------------------------------------------QUESTION 56
---------------------------------------------------------------------Which of the following is the correct location of compiled class files within a war file?
1)
2)

/META-INF/classes
/WEB-INF/bin

3)

/WEB-INF/bin/classes

4)

/WEB-INF/classes

5)

/contextroot/classes

A) 1
B) 2
C) 3
D) 4
E) 5
---------------------------------------------------------------------QUESTION 57
---------------------------------------------------------------------Which of the following methods finds the maximum number of connections that a specific driver
can obtain?

A. Database.getMaxConnections
B. Connection.getMaxConnections
C. DatabaseMetaData.getMaxConnections
D. ResultSetMetaData.getMaxConnections

---------------------------------------------------------------------A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 58
---------------------------------------------------------------------Which of the following pattern works as a bridge between two incompatible interfaces?
A - Builder Pattern
B - Adapter Pattern
C - Prototype Pattern
D - Filter Pattern
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 59
---------------------------------------------------------------------Which of
the following protocol is used in servlet ?
A. http
B. https
C. none of the above metioned
D. both A & B
A) A
B) B
C) C
D) D

QUESTION 60
---------------------------------------------------------------------Which of the following statement is true about servlet filter ?
A)A filter is a reusable piece of code that can transform the content of HTTP requests, responses
and header information.
B)Filters do not generally create a response or respond to a request as servlets do.
C)Filters can act on dynamic or static content.
D)All of the above
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 61
---------------------------------------------------------------------Which of the following represents the XML equivalent of this statement <%@ include
file=a.jsp%> . Select the one correct statement

A) <jsp:include file=a.jsp/>
B) <jsp:include page=a.jsp/>
C) <jsp:directive.include file=a.jsp/>
D) There is no XML equivalent of include directive. -------------------------------------------------------------------QUESTION 62
---------------------------------------------------------------------What is the output of the below code: class
OurCreatedException extends Exception{
OurCreatedException(){ super();
}
}
class XYZ{ public static void method(String name) throws
OurCreatedException{ if(name==null){
}
else{

throw new OurCreatedException();

---------------------------------------------------------------------System.out.println("Welcome "+name);
}
}
}
class Test{
public static void main(String[] args) {
XYZ.method("John");
}
}
A) Welcome John
B) null
C) Compilation fails
D) OurCreatedException thrown at run time
---------------------------------------------------------------------QUESTION 63
---------------------------------------------------------------------What is the output of the below code:
class Test{ public static void main(String[]
args) { try { int[] array
= {1,2,3,4,5};

for (int i = 0; i < 7; ++i)

{
System.out.print(array[i]);
}
} catch (ArrayIndexOutOfBoundsException e) {
System.out.print("0");
}
}
}
A) 12345
B) 123450
C) 12345
ArrayIndexOutOfBoundException
D) Compilation fails

---------------------------------------------------------------------QUESTION 64
---------------------------------------------------------------------What are the legal methods of HttpServletBindingListener?
A) a) attributeAdded(ServletContextAttributeEvent event)
b) attributeRemoved(ServletContextAttributeEvent event) B)
a) HttpSessionEventBound(HttpSession source)
b) HttpSessionEventUnbound(HttpSession source)
C) a) HttpSessionBindingEvent(HttpSession session, java.lang.String name)
b) HttpSessionBindingEvent(HttpSession session, java.lang.String name, java.lang.Object value)
D) a) valueBound(HttpSessionBindingEvent event)
b) valueUnbound(HttpSessionBindingEvent event)
---------------------------------------------------------------------QUESTION 65
---------------------------------------------------------------------How can you execute a stored procedure in the database?
A) Call method execute() on a CallableStatement object
B) Call method executeProcedure() on a Statement object
C) Call method execute() on a StoredProcedure object
D) Call method run() on a ProcedureCommand object
---------------------------------------------------------------------QUESTION 66
---------------------------------------------------------------------What type of Exception Occurs at the following snippet code:
Number n = new Integer(12);
Double d = (Double)n;
System.out.println(d);
A) NumberFormatException
B) ClassCastException
C) InputMisMatchException
D) None of the above

---------------------------------------------------------------------QUESTION 67
---------------------------------------------------------------------Add attribute, Remove attibute , Replace attribute method are implemented from
___________________ Interface

A) HttpSessionListener
B) HttpSessionAttributeListener
C) ServletContextListener
D) HttpSessionActivationListener
---------------------------------------------------------------------QUESTION 68
---------------------------------------------------------------------Assume the following method is properly synchronized and called from a thread A on an object B
wait(2000);
After calling this method , when will the thread A become a candidate to get another turn at the
CPU?
A) Two seconds after thread A is notified
B) After thread A is notified or after two seconds
C) Two seconds after lock B is released
D) After the lock on B is released or after two seconds
---------------------------------------------------------------------QUESTION 69
---------------------------------------------------------------------To execute "select * from tablename" query which method is used?
A) execute
B) executeQuery
C) executeUpdate
D) executeBatch
---------------------------------------------------------------------QUESTION 70

---------------------------------------------------------------------Which type of Statement can execute parameterized queries?


A) PreparedStatement
B) ParameterizedStatement
C) ParameterizedStatement and CallableStatement
D) All kinds of Statements
---------------------------------------------------------------------QUESTION 1
---------------------------------------------------------------------Servlet Instances are created by ?
A) init()
B) constructor
C) Servlet Container
D) none of the above mentioned
---------------------------------------------------------------------QUESTION 2
---------------------------------------------------------------------Which are the legal Stirng operations
A) s3= s1+s2;
B) s3= s1-s2;
C) s3= s1&s2;
D) s3= s1&&s2;
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 3
---------------------------------------------------------------------DriverManager.getConnection(____________)?
Fill up the blank.

A) getConnection(String url)
B) getConnection(String url, Properties info)
C) getConnection(String url, String user, String password)
D) All of the above mentioned
---------------------------------------------------------------------QUESTION 4
---------------------------------------------------------------------What is the output of the below code class
Test{
public static void main(String[] args) {
System.out.println(5.45+"3,2");
}
}
A) 5
B) 5.4
C) 5.453,2
D) Compilation Fails
---------------------------------------------------------------------QUESTION 5
---------------------------------------------------------------------What is the output of the below snippet code:
File f = new File("D:\\workspace\\DemoPrograms\\samplefile.txt");
System.out.println(f.getAbsolutePath());
A) D:\\workspace\\DemoPrograms\\samplefile.txt
B) D:\workspace\DemoPrograms\samplefile.txt
C) workspace\DemoPrograms\samplefile.txt
D) workspace\\DemoPrograms\\samplefile.txt
---------------------------------------------------------------------QUESTION 6
---------------------------------------------------------------------Which Listeners counts the number of user logged in?

A) HttpSessionListener
B) HttpBindingEventListener
C) RequestListener
D) ResponseListener
---------------------------------------------------------------------QUESTION 7
---------------------------------------------------------------------What is the output of the below code:
class X{
int a;
static int a; int
Add(){ return
a;
}
}
A) 0
B) No Ouput
C) Compilation fails
D) Run time error
---------------------------------------------------------------------QUESTION 8
---------------------------------------------------------------------What gets printed when the following expression is evaluated? Select the one correct answer.
${(1==2) ? 4 : 5}

A) 1
B) 2
C) 4
D) 5
---------------------------------------------------------------------QUESTION 9
----------------------------------------------------------------------

setAutoCommit(boolean autoCommit) is method of ___________ Interface


A) ResultSet
B) Connection
C) Statement
D) HttpSession
---------------------------------------------------------------------QUESTION 10
---------------------------------------------------------------------Given:
10 . interface Jumper { public void jump(); } ...
20 . class Animal {} ...
30. class Dog extends Animal {
31. Tail tail; 32. } ...
40. class Beagle extends Dog implements Jumper {
41. public void jump() {}
42. } ...
50. class Cat implements Jumper {
51. public void jump() {}
52. }
Which three are true? (Choose three.)
A. Cat is-a Animal
B. Cat is-a Jumper
C. Dog is-a Animal
D. Dog is-a Jumper
E. Cat has-a Animal
F. Beagle has-a Tail
G. Beagle has-a Jumper
A) A,B,D
B) AF,G
C) B,F,G
D) B,C,F E) E,F,G

---------------------------------------------------------------------QUESTION 11

---------------------------------------------------------------------What is the output of the below code:


< c:forTokens items="One,Two,Three,Four.Five.Six" delims="," var="data" >
<c:out value="${data}"/><br/>
< /c:forTokens >
A) One Two
Three
Four.Five.Six
B) One Two
Three
Four
Five
Six
C) Compilation fails
D) Run time error
---------------------------------------------------------------------QUESTION 12
---------------------------------------------------------------------Dog sub class is extending supercalss Mammal,How will represent using UML?
A) Filled diamond on side of the Super class
B) Hollow triangle shape on the superclass end of the
line C) Hollow diamond on the Collection side
D) Hollow triangle shape on the subrclass end of the line
---------------------------------------------------------------------QUESTION 13
---------------------------------------------------------------------The sendError method defined in the HttpServlet class is equivalent to invoking the setStatus
method with the following parameter. Select the one correct answer.

A. SC_OK
B. SC_MOVED_TEMPORARILY
C. SC_NOT_FOUND

D. SC_INTERNAL_SERVER_ERROR
E. ESC_BAD_REQUEST
A) A
B) B
C) C
D) D E) E

---------------------------------------------------------------------QUESTION 14
---------------------------------------------------------------------What is the output of the below code:
interface I1{
int m1();
}
class Test{ public static void
main(String[] args) {
System.out.println(new I1(){ public
int m1() { return 2;
}
});
}
}
A) 2
B) Class Name appended with hashcode
C) Compilation fails
D) Run time error
---------------------------------------------------------------------QUESTION 15
---------------------------------------------------------------------What is the output of the below code:
int[] array = {0,1,2,3};
array.clear(2);
System.out.println(array);

A) {0,1,3}
B) {2,3}
C) {0,1}
D) Compilation Fails
---------------------------------------------------------------------QUESTION 16
---------------------------------------------------------------------What is the output of the below code:
StringBuffer s = new StringBuffer("Hello");
StringBuffer s1 = new StringBuffer("World");
s.append(s1); System.out.println(s);

A) Hello
B) World
C) Hello World
D) Compilation Fails
---------------------------------------------------------------------QUESTION 17
---------------------------------------------------------------------Given:

class One{

public One method(){ return


this;
}
}
class Two extends One{
public Two method(){ return
this;
}
}
public class DemoProgram extends Two{
//Expected Code Here
}
A) public void method(){

}
B) public int method(){ return
3;
}
C) public One method(){
return this;
}
D) public Two method(){
return this;
}
---------------------------------------------------------------------QUESTION 18
--------------------------------------------------------------------class
Parent{ void method(){ System.out.println("Parent");
}
}
class Child extends Parent{
void method(){
System.out.println("Child");
}
public static void main(String[] args) {
Parent p = new Parent();
Child c = (Child)p; c.method();
}
}
A) Child
B) Parent
C) Compilation fails
D) ClassCastException thrown at runtime
---------------------------------------------------------------------QUESTION 19 ---------------------------------------------------------------------- What
is the ouput of the below syntax:
String s = "IDEAL";

System.out.println(s.substring(0, s.length()-1)+(s.charAt(s.length()-1)));
A) IDE
B) IDEAL
C) IDEA
D) Compilation Fails
---------------------------------------------------------------------QUESTION 20
---------------------------------------------------------------------- class
Dog{
}
class Poodle extends Dog{ public
static void main(String[] args){
Dog ruff = new = new Poodle();
Poodle puddles = (Poodle)ruff;/* line no 6*/
}
}
What type of casting is occuring at line no 6?
A) UpCasting
B) DownCasting
C) BroadCasting
D) none of the above mentioned
---------------------------------------------------------------------QUESTION 21
---------------------------------------------------------------------Given: interface A{} class C{}
class D
extends C{} public class Test extends
D{ public static void main(String[]
args) { Test t = new Test(); if(t
instanceof A){
System.out.println("instance of A");
}else if(t instanceof C)

{
System.out.println("instance of C");
}
else if(t instanceof D)
{
System.out.println("instance of D");
}
else{
System.out.println("Hello World");
}
}
}
} What is the ouput of the below code?
A) instance of A
instance of D B)
instance of
C instance of D
C) instance of C
D) instance of C
E) Compilation Fails
---------------------------------------------------------------------QUESTION 22
---------------------------------------------------------------------Which of these is a correct example of specifying a listener element resented by MyClass class.
Assume myServlet element is defined correctly. Select the one correct answer.
A. <listener>MyClass</listener>
B. <listener> <listener-class>MyClass</listener-class></listener>
C. <listener> <listener-name>aListener</listener-name> <listener-class>MyClass</listener-class>
< /listener >
D. <listener> <servlet-name>myServlet</servlet-name> <listener-class>MyClass</listener-class>
< /listener >

A) A
B) B
C) C

D) D
---------------------------------------------------------------------QUESTION 23
---------------------------------------------------------------------Which result set generally does not show changes to the underlying database that are made while
it is open. The membership, order, and column values of rows are typically fixed when the result
set is created?
A) TYPE_FORWARD_ONLY
B) TYPE_SCROLL_INSENSITIVE
C) TYPE_SCROLL_SENSITIVE
D) ALL MENTIONED ABOVE
---------------------------------------------------------------------QUESTION 24
---------------------------------------------------------------------Which three of the following are true about servlet filters?
a)A filter must implement the destroy method
b)

A filter must implement the do Filter method

c)

A servlet may have multiple filters associated with it

d)

A servlet that is to have a filter applied to it must implement the javax.servlet.FilterChain


interface

e)

A filter that is part of a filter chain passes control to the next filter in the chain by invoking

theFilterChain forward method

A) a,b,c
B) c,d,e
C) b,d,e
D) a,d,e
---------------------------------------------------------------------QUESTION 25
---------------------------------------------------------------------Which two of the following statements are true?
a)The doFilter method is always invoked by the container, never within a programmers code
b)A filter can be invoked either through being declared in WEB.XML or explicitly within

aprogrammers code
c)Filters are associated with a URL via the filter-mapping tag
d)Filters can be initialised via the filter-init-param tag in the deployment descriptor
e)Filters can be initialised via the init-param tag in the deployment descriptor
A) a,c
B) d,e
C) b,e
D) c,e
---------------------------------------------------------------------QUESTION 26
---------------------------------------------------------------------Which type of ResultSet can be navigated in both directions and will reflect the changes made to
the underlying data in the Database?

A) TYPE_FORWARD_ONLY
B) TYPE_SCROLL_INSENSITIVE
C) TYPE_SCROLL_SENSITIVE
D) ALL MENTIONED ABOVE
---------------------------------------------------------------------QUESTION 27
---------------------------------------------------------------------Write the valid code to get the month?
public class Test {
public static void main(String[] args) {
Calendar calendar = new GregorianCalendar();
//insert code here
System.out.println(month);
}
}
A) int month

= calendar.get(Calendar.DAY_OF_MONTH);

B) int month

= calendar.get(Calendar.MONTH);

C) int month
D) int month

= calendar.get(MONTH);
= calendar.get(MONTH);

---------------------------------------------------------------------QUESTION 28
---------------------------------------------------------------------You want to create families of related objects, to be used interchangeably to configure you
application. What is the most appropriate pattern to use?

A) Factory
B) Builder
C) Abstract Factory
D) Composite
---------------------------------------------------------------------QUESTION 29
---------------------------------------------------------------------What is the output of the below code:
class Test{ public static void
main(String[] args) { Stack<String>
data = new Stack(); data.add("test");
data.add("hello");
data.add(123);
System.out.println(data);
}
}
A) test hello
123
B) test hello
C) Compil
ation
fails
D) run time
error ----------------------------------------------------------------

QUESTION 30
---------------------------------------------------------------------class
Test{ public static void main(String[] args) {
HashMap map = new
HashMap(); map.put(null, "one");
map.put(null,"two"); map.put(3,
"three"); map.put(4, "four");
Iterator entries = map.entrySet().iterator();
while(entries.hasNext()){
Map.Entry entry = (Map.Entry) entries.next();
System.out.println("key "+entry.getKey()+" value "+entry.getValue());
}
}
}
What is the ouput of the above code?
A)

key null

value null key null


value two key 3
value three key 4
value four
B)

key null

value one two key 3


value three key 4
value four C) key null
value two key 3
value three key 4
value four D) None
of the above

---------------------------------------------------------------------QUESTION 31
---------------------------------------------------------------------What is the output of the below code:
class Test{
public static void main(String[] args) {

StringBuffer buffer = new


StringBuffer("HelloWorld"); buffer.insert(5, "test");
System.out.println(buffer);
}
}
A) Hellotest
B) HellotestWorld
C) Compilation fails
D) Runtime error
---------------------------------------------------------------------QUESTION 32
---------------------------------------------------------------------Which listener help to get the information about the how many user's are available currently ?
A) HttpSession
B) HttpSessionListener
C) Session
D) HttpRequest
---------------------------------------------------------------------QUESTION 33
---------------------------------------------------------------------Given:
interface Foo { int bar(); } public class Test {
public static int fubar( Foo foo ) { return foo.bar(); }
public void testFoo() { fubar(/*Insert Code here*/);
}
}
Which code allows the class Test to compile?
A. Foo { public int bar() { return 1; }
B. new Foo { public int bar() { return 1; }
C.new Foo() { public int bar() { return 1; }}
D. new class Foo { public int bar() { return 1; }

A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 34
---------------------------------------------------------------------What is
the syntatical error in the below code:
abstract class Sum{
abstract abc(int m,int n);
}
A) body of the method is missing
B) class modifier needs to be changed to public
C) method return type is missing
D) abstract modifier near the method should be changed to public
---------------------------------------------------------------------QUESTION 35
---------------------------------------------------------------------What is the output of the below code: public
class Test{
public static void main(String[] args) {
String s = new String("IBM");
System.out.println(s.length());
}
}
A) 2
B) 3
C) Compilation fails
D) runtime error
---------------------------------------------------------------------QUESTION 36 ----------------------------------------------------------------------

If conn is the Connection Object, What will happen if the following line of code gets executed:
conn.setAutoCommit(false);
A) SQL statement is treated as a transaction and is automatically committed
B) SQL statement is treated as a transaction and manually needs to be committed
C) both a & b
D) none of the above
---------------------------------------------------------------------QUESTION 37
---------------------------------------------------------------------AutoCommit, rollback,Savepoint all this methods belong to _____________________
A) DriverManager
B) Connection Interface
C) Statement
D) ResultSet
---------------------------------------------------------------------QUESTION 38
---------------------------------------------------------------------What is the output for the below
code? public class A { public A() {
System.out.println("A")
}}
public class B extends A implements Serializable {
public B() {
System.out.println("B")
}} public class Test { public static void main(String...
args) throws Exception {
B b = new B()
ObjectOutputStream save = new
ObjectOutputStream(new FileOutputStream("datafile"))
save.writeObject(b) save.flush()
ObjectInputStream restore = new ObjectInputStream(new
FileInputStream("datafile"))

B z = (B) restore.readObject()
}}
A) A B A B
B) A B
C) B A B
D) A B A
---------------------------------------------------------------------QUESTION 39
---------------------------------------------------------------------What is the output of the below code: class
Test{
public static void main(String[] args) {
String str = "Good Morning";
str.concat("Hello");
System.out.println(str);
}
}
A) Good Morning
B) Good Morning Hello
C) Compilation fails
D) runtime error
---------------------------------------------------------------------QUESTION 40
---------------------------------------------------------------------What is the output of the below code:
class Test{
public static void main(String[] args) {
StringBuffer buffer = new StringBuffer("Good");
buffer.reverse(); System.out.println(buffer);
}
}
A) dooG

B) Good
C) Compilation fails
D) runtime error
---------------------------------------------------------------------QUESTION 41
---------------------------------------------------------------------A team of programmers is reviewing a proposed API for a new utility class. After
some discussion, they realize that they can reduce the number of methods in the API
without losing any functionality. If they implement the new design, which two OO
principles will they be promoting? A. Looser coupling
B. Tighter coupling
C. Lower cohesion
D. Higher cohesion
E. Weaker encapsulation
A) A
B) B
C) C
D) D E) E

---------------------------------------------------------------------QUESTION 42
---------------------------------------------------------------------A team of programmers is involved in reviewing a proposed design for a new utility
class. After some discussion, they realize that the current design allows other classes
to access methods in the utility class that should be accessible only to methods
within the utility class itself. What design issue has the team discovered?
A. Tight coupling
B. Low cohesion
C. High cohesion
D. Weak encapsulation
E. Strong encapsulation
A) A
B) B
C) C
D) D

E) E
---------------------------------------------------------------------QUESTION 43
---------------------------------------------------------------------What is the ouput of the below code:
import java.io.*; class Chararrayinput {
public static void main(String[] args) {
String obj = "abcdef";
int length =
obj.length();
char c[] = new
char[length];
obj.getChars(0, length,
c, 0);
CharArrayReader input1 = new CharArrayReader(c);
CharArrayReader input2 = new CharArrayReader(c, 0, 3);
i;
try {
while((i = input2.read()) != -1) {
System.out.print((char)i);
}
}

catch (IOException e) {

e.printStackTrace();
}
}
}
A) abc
B) abcd
C) abcde
D) abcdef
---------------------------------------------------------------------QUESTION 44
---------------------------------------------------------------------What is the outputof the below code:
package com.manipal.demo; public
class DemoProgram { public static
void main(String[] args) {
= DemoProgram.class;

Class cls

int

System.out.println(cls.getName());
}
}
A) DemoProgram
B) com.manipal.demo.DemoProgram
C) Compilation fails
D) runtime error
---------------------------------------------------------------------QUESTION 45
---------------------------------------------------------------------Which
Servlet Abstract Class has destroy() and init() ?

A) Servlet Interface
B) HttpServlet
C) Generic Servlet
D) none of the above
---------------------------------------------------------------------QUESTION 46
---------------------------------------------------------------------What is the output of the below code
< c:forTokens items="a,b,c,d,e" delims="," var="character" begin="0" end="4" step="2" >
<p> <c:out value="${character}"/><p>
< /c:forTokens >
A) c d e
B) a d e
C) a c e
D) b d e

---------------------------------------------------------------------QUESTION 47
---------------------------------------------------------------------Which is incorrect about AbstractFactory Pattern

A. Application should be configured with one of the multiple families of products.


B. To be compatible, objects should be created as a set.
C. These are concerned with how to form larger structures by composing classes and objects.
D. You want to provide a collection of classes, and reveal just their contracts, and relationships,
not their implementations.

A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 48
---------------------------------------------------------------------What is the output of the below code:
public class DemoProgram { public static
void main(String[] args) {
System.out.println(5+4+"String"+7+1);
}
}
A) 54String71
B) 9String8
C) 9String71
D) 54String8
---------------------------------------------------------------------QUESTION 49
---------------------------------------------------------------------Which method of ResultSet can be used to jump to the third row in the database"
A) rs.next(3)
B) rs.moveTo(3)
C) rs.getXXX(3)
D) rs.absolute(3)
E) none of the above

---------------------------------------------------------------------QUESTION 50
---------------------------------------------------------------------What is the output of the below code:
public class DemoProgram { public
static void main(String[] args) {
double
x = 60984.123;
double y =
-497.99;
System.out.println(Math.floor(x)+" "+Math.floor(y)+" "+Math.floor(0));
}
}
A) 60984.2 -498.0 0.1
B) 60984.2 -498.1 0.0
C) 60984.0 -498.0 0.0
D) 60984.0 -498.0 0.0
E) Compilation fails
---------------------------------------------------------------------QUESTION 51
---------------------------------------------------------------------What is the output of the below code:
public class DemoProgram { public
static void main(String[] args) { String
str = "Hello World";
str.addAtIndex(5,"test");
}
}
A) HellotestWorld
B) Hellotest
C) Compilation fails
D) runtime error
---------------------------------------------------------------------QUESTION 52
----------------------------------------------------------------------

What is the output of the below code:


public class DemoProgram { public
static void main(String[] args) { try{ int
a=0,b=10; int c=a/b;
System.out.println("Hello");
}catch(ArithmeticException e){
System.out.println("world");
}
}
}
A) world
B) Hello
C) ArithmeticException
D) Compilation fails
---------------------------------------------------------------------QUESTION 53
---------------------------------------------------------------------Which is
the primitive data type of c in the below synatx:
? C = 57.659
A) float
B) Float
C) double
D) Double
---------------------------------------------------------------------- QUESTION 54
---------------------------------------------------------------------Whats is the output of the below code:
package com.manipal.demo; public class
DemoProgram { public static void main(String[]
args) { DemoProgram demo = new
DemoProgram();
System.out.println(demo.getClass());
}

}
A) com.manipal.demo.DemoProgram
B) class DemoProgram
C) DemoProgram
D) class com.manipal.demo.DemoProgram
---------------------------------------------------------------------QUESTION 55
---------------------------------------------------------------------Authentication can be done by
A) Basic
B) Form-Based
C) Digest
D) All of the above
E) none of the above
---------------------------------------------------------------------QUESTION 56
---------------------------------------------------------------------Which of the following is the correct order of servlet life cycle phase methods?
A - init(), service(), destroy()
B - initialize(), service(), destroy()
C - init(), execute(), destroy()
D - init(), service(), delete()
A) A
B) B
C) C
D) D
----------------------------------------------------------------------

QUESTION 57
---------------------------------------------------------------------Which of the following code retrieves the body of the request as binary data?
A - new InputStream()
B - response.getInputStream()
C - request.getInputStream()
D - None of the above.
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 58
---------------------------------------------------------------------class
Test {

public static void main(String[] args) {

Thread t1 = new Thread(new Runnable() { public void


run() { System.out.println("Thread running");}
});
System.out.println(new Runnable() { public
void run() {System.out.println("running");}
});
t1.start();
}
}
What is the output of the above code?
A) Thread running
B) No Output
C) Compilation fails
D) runtime error

---------------------------------------------------------------------QUESTION 59
---------------------------------------------------------------------class
Test {
public static void main(String[] args) {
List<Object> list = new ArrayList<String>();/*error at line
3*/ list.add("test");/*error at line 4*/ list.add(new
Integer(1));/*error at line 5*/ list.add(new
Double(1.23223));/*error at line 6*/ list.add(12.3f);/*error at
line 7*/
}
}
A) test
1
1.23223
12.3
B) Error at line 3
C) Error at line
4
D) Error at line 5
E) Error at line 6
F) Error at line 7
---------------------------------------------------------------------QUESTION 60
---------------------------------------------------------------------- Which statement is valid for the below
syntax: while(i<10 && i >24){
}
A) while loop never executes always true
B) while loop never executes always false
C) Compilation fails
D) Exception thrown at run time
---------------------------------------------------------------------QUESTION 61

---------------------------------------------------------------------What is the value and data type for the below code:
2+3*5 = ?
A) 17 int
B) 25 int
C) 17 byte
D) 25 byte
---------------------------------------------------------------------QUESTION 62
---------------------------------------------------------------------How to get Warning from Statement?
A) getWarnings()
B) getWarningsFromStatement() C)
getNextWarning()
D) None of the above mentioned
---------------------------------------------------------------------QUESTION 63
---------------------------------------------------------------------What is the output of the below code: public
class Test {
public static void main(String[] args) { List<Integer>
list = new ArrayList<Integer>(); list.add(9);
list.add(8); list.add(2); list.add(1);
Collections.reverse(list);
Collections.sort(list);
Iterator itr = list.iterator();
Collections.shuffle(list); while(itr.hasNext()){
System.out.println(itr.next());
}
}
}
A) 9 8 2 1

B) 1 2 8 9
C) 2 9 1 8
D) Non-Predicatable
---------------------------------------------------------------------QUESTION 64
---------------------------------------------------------------------What is the value of the counter variable in the below
code: public class X implements
HttpSessionBindingListener { public static int counter; public
void valueBound(HttpSessionBindingEvent event) {
counter++;
}
public void valueUnbound(HttpSessionBindingEvent event) {
counter++;
}
}
public class TestBinding extends HttpServlet { public void
doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,
IOException {
HttpSession session = req.getSession();
X x = new X();
session.setAttribute("name",x);
session.setAttribute("name",new X());
session.setAttribute("test",new X());
session.getAttribute("name");
session.removeAttribute("name");
}
}
A) 1
B) 2
C) 3
D) 4
---------------------------------------------------------------------QUESTION 65

---------------------------------------------------------------------What type of exception occurs in the below code:


class Test{ public static void main(String[]
args) { try{ int[] array = {1,3,5,6};
System.out.println(array[-1]);
}catch(NegativeArraySizeException ne){
ne.printStackTrace();
}
catch(ArrayIndexOutOfBoundsException ae){
ae.printStackTrace();
}
}
}
A) NegativeArraySizeException
B) ArrayIndexOutOfBoundsException
C) both a & b
D) none of the above mentioned
---------------------------------------------------------------------QUESTION 66
---------------------------------------------------------------------Given the code fragment:
1. ArrayList<Integer> list = new ArrayList<>(1);
2. list.add(1001);
3. list.add(1002);
4. System.out.println(list.get(list.size())); What is the result?
A) Compilation fails due to an error on line 1.
B) An exception is thrown at run time due to error on line 3
C) Anexception is thrown at run time due to error on line 4
D) 1001 1002
---------------------------------------------------------------------QUESTION 67
---------------------------------------------------------------------What happens if you call the method close() on a ResultSet object?

A) the method close() does not exist for a ResultSet. Only Connections can be closed. B)
the database and JDBC resources are released
C) you will get a SQLException, because only Statement objects can close ResultSets
D) the ResultSet, together with the Statement which created it and the Connection from which the
Statement was retrieved, will be closed and release all database and JDBC resources
---------------------------------------------------------------------QUESTION 68
---------------------------------------------------------------------Which type of driver converts JDBC calls into the network protocol used by the database
management system directly?

A) Type 1 driver
B) Type 2 driver
C) Type 3 driver
D) Type 4 driver
---------------------------------------------------------------------QUESTION 69
---------------------------------------------------------------------How can you retrieve information from a ResultSet?
A) By invoking the method get(..., String type) on the ResultSet, where type is the database type
B) By invoking the method get(..., Type type) on the ResultSet, where Type is an object which
represents a database type
C) By invoking the method getValue(...), and cast the result to the desired Java type.
D) By invoking the special getter methods on the ResultSet: getString(...), getBoolean (...),
getClob(...)

---------------------------------------------------------------------QUESTION 70
---------------------------------------------------------------------Choose the approriate way to synchronize static from contents with jsp?
A) <jsp:setProperty name="bean" property="username" />
B) <jsp:setProperty name="bean" property="*" />

C) <jsp:setProperty name="bean" value="test"/>


D) None of the above
---------------------------------------------------------------------QUESTION 71
---------------------------------------------------------------------- cf
command to deploy in load server

A) cf.push
B) cf.publish
C) cf.deploy
D) none of the above
---------------------------------------------------------------------QUESTION 72
---------------------------------------------------------------------When a session is moved from one JVM and created on another JVM in a distributed
environment, Which Listener and method can be used to capture this event of session creation on
another JVM and take action?

A) sessionWillPassivate method of HttpSessionActivationListener


B) sessionCreated method of HttpSessionListener
C) attributeAdded method of HttpSessionAttributeListener
D) sessionDidActivate method of HttpSessionActivationListener
---------------------------------------------------------------------QUESTION 73
---------------------------------------------------------------------What is the output for the below code
? class Test{ public static void
main(String args[]){ try{
System.out.println("one");
System.exit(0);
} catch(Exception e ){
System.out.println("two"); }
finally{
System.out.println("three");

}
}
}
A) one
B) one two
C) one two three
D) two three
---------------------------------------------------------------------QUESTION 74
---------------------------------------------------------------------What will be the output of the program? public
class Animal
{ public static void main(String []
args)
{
Dog [][] theDogs = new Dog[3][]
System.out.println(theDogs[2][0].toString())
}}
class Dog { }
A) null
B) theDogs
C) Compilation fails
D) An exception is thrown at runtime
---------------------------------------------------------------------QUESTION 75
---------------------------------------------------------------------What will be the output of the below
code class Employee{ Employee(){
System.out.println(1);
} void
test(){
this();

System.out.println(2); }
}
class Manager
{
public static void main(String args[]){
Employee e1=new Employee();
}}
A) 1
B) 2
C) compile time error
D) run time error

QUESTION 1
-------------------------------------------------------------------public class Test { public static void main (String[] args)
{ new Test().go();
}
public void go() {
Runnable r = new Runnable() { public void run() { System.out.print("foo"); }
};
Thread t = new Thread(r);
t.start();
t.start(); } }
What is the result?
A) An exception is thrown at runtime.
B) Compilation fails.
C) The code executes normally and prints "foo".
D) The code executes normally, but nothing is printed.
---------------------------------------------------------------------QUESTION 2
---------------------------------------------------------------------Which Man class properly represents the relationship "Man has a best friend who is a Dog"?
A) class Man extends Dog { }

B) class Man implements Dog { }


C) class Man { private BestFriend dog; }
D) class Man { private Dog bestFriend; }
E) class Man { private Dog<bestFriend>; }
---------------------------------------------------------------------QUESTION 3
---------------------------------------------------------------------class
Animal
{
String name = "animal";
String makeNoise() { return "generic noise"; }
}
class Dog extends Animal
{
String name = "dog";
String makeNoise() { return "bark"; }
}
public class Test
{ public static void main(String[]
args)
{
Animal an = new Dog();
System.out.println(an.name+" "+an.makeNoise());
}
}
A) animal generic noise
B) animal bark
C) dog bark
D) dog generic noise
---------------------------------------------------------------------QUESTION 4
---------------------------------------------------------------------Consider the code

int[] x = {5,6,7,8,9}; int[]


y = x; y[2] =
10;
What is the value of x[2]?
A) 6
B) 7
C) 8
D) 10 E) 0

---------------------------------------------------------------------QUESTION 5
---------------------------------------------------------------------class MyThread implements Runnable {
public void run(){
System.out.println("Running MyThread");
}
} // end of MyThread class
YourThread extends Thread { public
YourThread(Runnable r) { super(r);
}
public void run(){
System.out.println("Running YourThread");
}
} // end of YourThread
public class Test {
public static void main(String args[]) {
MyThread t1 = new MyThread(); YourThread
t2 = new YourThread(t1);
t2.start();
}
}
What will be the ouput of the above Code?
A) Running MyThread

B) Running YourThread
C) Running MyThread
Running YourThread
D) Compilation fails
E) Runtime error
---------------------------------------------------------------------QUESTION 6
---------------------------------------------------------------------Steps for creating a Custom tag(Re-arrange)
A. Package Tag Handlers and TLD file into tag library
B. Write TLD file
C. Write Tag Handlers
D. Reference the TLD in the web-app deployment descriptor
A) A,B,D,C
B) D,C,B,A
C) B,C,A,D
D) A,C,D,B,
---------------------------------------------------------------------QUESTION 7
---------------------------------------------------------------------Which type of ResultSet can be navigated in both directions and will reflect the changes made to
the underlying data in the Database?

A) TYPE_FORWARD_ONLY
B) TYPE_SCROLL_INSENSITIVE
C) TYPE_SCROLL_SENSITIVE
D) ALL MENTIONED ABOVE
---------------------------------------------------------------------QUESTION 8
---------------------------------------------------------------------Design Pattern in which we separate abstraction and its implementation?
A) Decorator Pattern

B) Adapter Pattern
C) Bridge Pattern
D) Creational Pattern
---------------------------------------------------------------------QUESTION 9
---------------------------------------------------------------------What is the sequence of method execution in Filter?
A)init,doFilter,destroy
B)doFilter,init,destroy
C)destroy,doFilter,init
D)destroy,doFilter
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 10
---------------------------------------------------------------------All ____________ are notified of context initialization before any filter or servlet in the web
application is initialized.
A) ServletContextListeners
B) HttpSessionListener
C) ServletRequestListener
D) All of the above
---------------------------------------------------------------------QUESTION 11
---------------------------------------------------------------------public
Object m()
{
Object o = new Float(3.14F) Object []
oa = new Object[l]/* Line 5 */ oa[0] = o
/* Line 6 */ o = null /* Line 7*/ oa[0]

= null /* Line 8 */ return o /* Line 9 */


}
When is the Float object, created in line 3, eligible for garbage collection?
A) just after line 5
B) just after line 6
C) just after line 7
D) just after line 8
E) just after line 9
---------------------------------------------------------------------QUESTION 12
---------------------------------------------------------------------Given: public interface A{public void m1();}
class B
implements A{} class C implements A {public void
m1(){}} class D implements A{public void m1(int x){}}
abstract class E implements A{} abstract class F
implements A{public void m1(){}} abstract class G
implements A{public void m1(int x){}}
What is the result
A) compilation succeeds
B) Exactly one class does NOT compile
C) Exactly two classes do NOT compile
D) Exactly four classes do NOT compile
E) Exactly three classes do NOT compile
---------------------------------------------------------------------QUESTION 13
---------------------------------------------------------------------What is the output of below code?
public class Bean{
private String str
Bean(String str ){ this.str
= str } public String
getStr() { return str

}
public boolean equals(Object o){
if (!(o instanceof Bean)) { return
false
} return ((Bean)
o).getStr().equals(str)
}
public int hashCode() {
return 12345
} public String toString()
{ return str
}
}
import java.util.HashSet public class
Test { public static void main(String
... sss) {
HashSet myMap = new HashSet()
String s1 = new String("das")
String s2 = new String("das")
Bean s3 = new Bean("abcdef")
Bean s4 = new Bean("abcdef")
myMap.add(s1) myMap.add(s2)
myMap.add(s3) myMap.add(s4)
System.out.println(myMap)
}
}
A) das abcdef
B) das abcdef das abcdef
C) das das abcdef abcdef
D) das
---------------------------------------------------------------------QUESTION 14
---------------------------------------------------------------------What is the output of the below code:
import java.util.*;

class genericstack

<E> {
Stack <E> stk = new Stack
<E>(); public void push(E obj) {
stk.push(obj);
}
public E pop() {
E obj = stk.pop();

return

obj;
}
}
public class Test {

public static void main(String args[]) {

genericstack <String> gs1 = new genericstack<String>();


System.out.print(gs1.pop() + " ");
<Integer> gs2 = new genericstack<Integer>();

gs1.push("Hello");

genericstack
gs2.push(36);

System.out.println(gs2.pop());
}
}
A) Hello
B) 36
C) compile time error
D) run time error
E) Hello 36
---------------------------------------------------------------------QUESTION 15
---------------------------------------------------------------------What will be the output of the below code: if(
"Welcome".trim() == "Welcome".trim() )
System.out.println("Equal"); else
System.out.println("Not Equal");
A) compile and display Equal
B) compile and display Not Equal
C) cause a compiler error
D) compile and display NULL ---------------------------------------------------------------------QUESTION 16

---------------------------------------------------------------------What is the output of the below code: import


java.util.*; public class Test {
private String s; public Test(String s)
{ this.s = s; } public static void
main(String[] args) { HashSet hs =
new HashSet();
Test ws1 = new Test("aardvark");
Test ws2 = new Test("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());
} }
A) 1
B) 2
C) 3
D) 4
E) 5
---------------------------------------------------------------------QUESTION 17

---------------------------------------------------------------------A bean with a property color is loaded using the following statement
< jsp:usebean id="fruit" class="Fruit"/ >
What happens when the following statement is executed. Select the one correct answer.
< jsp:setProperty name="fruit" property="*"/ >
A)This is incorrect syntax of <jsp:setProperty/> and will generate a compilation error. Either value
or param must be defined.
B)All the properties of the fruit bean are initialized to a value of null.
C)All the properties of the fruit bean are assigned the values of input parameters of the JSP page
that have the same name.
D)All the properties of the fruit bean are initialized to a value of *.
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 18
---------------------------------------------------------------------The sendRedirect method defined in the HttpServlet class is equivalent to invoking the setStatus
method with the following parameter and a Location header in the URL. Select the one correct
answer.
A) SC_OK
B) SC_MOVED_TEMPORARILY
C) SC_NOT_FOUND
D) SC_INTERNAL_SERVER_ERROR
E) ESC_BAD_REQUEST
A) A
B) B
C) C
D) D E) E

---------------------------------------------------------------------QUESTION 19

---------------------------------------------------------------------To send binary output in a response, the following method of HttpServletResponse may be used
to get the appropriate Writer/Stream object. Select the one correct answer.

A) getStream
B) getOutputStream
C) getBinaryStream
D) getWriter
---------------------------------------------------------------------QUESTION 20
---------------------------------------------------------------------Name the class that has getSession method, that is used to get the HttpSession object.
A) HttpServletRequest
B) HttpServletResponse
C) SessionContext
D) SessionConfig
---------------------------------------------------------------------QUESTION 21
--------------------------------------------------------------------import
java.io.*; public class Test {
public static void main(String[] args) {
String s1 = "abc";
String s2 = "def";
String s3 = s1.concat(s2.toUpperCase());
System.out.println(s1+s2+s3);
}
}
What is the output of the above code ?
A) abcDEF
B) abcdefabcdef
C) abcdefDEF
D) abcdefabcDEF

---------------------------------------------------------------------QUESTION 22
---------------------------------------------------------------------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
B) java.util.LinkedHashMap
C) java.util.HashMap
D) java.util.TreeMap
---------------------------------------------------------------------QUESTION 23
---------------------------------------------------------------------Given:

class

Mammal { }
class Raccoon extends Mammal {
Mammal m = new Mammal();
}
class BabyRaccoon extends Mammal { }
Which four statements are true? (Choose four.)
A. Raccoon is-a Mammal.
B. Raccoon has-a Mammal. C. BabyRaccoon is-a Mammal.
D. BabyRaccoon is-a Raccoon.
E. BabyRaccoon has-a Mammal.
F. BabyRaccoon is-a BabyRaccoon.
A) A,B,D,C
B) A,C,E,F
C) C,D,E,A
D) A,B,C,F
E) A,D,E,F
----------------------------------------------------------------------

---------------------------------------------------------------------QUESTION 24

--------------------------------------------------------------------class
Animal { public String noise() { return "peep"; } } class
Dog extends Animal { public String noise() { return
"bark"; }
}
class Cat extends Animal { public
String noise() { return "meow"; }
}
class Test{
public static void main(String[] args) {
Animal animal = new Dog();
Cat cat = (Cat)animal;
System.out.println(cat.noise());
}
}
What is the output of the above code?
A) peep
B) bark
C) meow
D) Compilation fails.
E) An exception is thrown at runtime
---------------------------------------------------------------------QUESTION 25
---------------------------------------------------------------------Which of the following interfaces has getWriter() method?
A) HttpServletRequest
B) HttpServletResponse
C) ServletRequest
D) ServletResponse
---------------------------------------------------------------------QUESTION 26
---------------------------------------------------------------------- What is the output of the below code:
public class Test { public static void

main(String[] args) { big_loop: for


(int i = 0; i < 3; i++) { try { for (int j = 0;
j < 3; j++) {
if (i==j) continue;
else
if (i>j) continue big_loop;
System.out.print("A ");
} } finally
{
System.out.print("B ");
}
System.out.print("C ");
}}}
A) A B C A B C A B C
B) A A B C A A A B C A A A B C
C) A A B B C A C A
D) A A B C B B
---------------------------------------------------------------------QUESTION 27
--------------------------------------------------------------------Choose
the incorrect option for Singleton pattern A) Provide a
default Private constructor.
B) Define a static Private object instance.
C) The client should be independent of how the products are created D)
Make the access method synchronized to prevent Thread problems.
E) Override the object clone method to prevent cloning.
A) A
B) B
C) C
D) D
E) E
---------------------------------------------------------------------QUESTION 28
----------------------------------------------------------------------

This method is used to execute any SQL statement with a "SELECT" clause, that returns the
result of the query as a result set.
A. executeUpdate();
B. executeQuery();
C. execute();
A) A
B) B
C) C
---------------------------------------------------------------------QUESTION 29
---------------------------------------------------------------------What is the output of the below code, public
class Test {
public static void main(String[] args) {
System.out.println("String "+new Integer("4")+5);
} }
A) String 9
B) String 45
C) compilation error
D) run time error
---------------------------------------------------------------------QUESTION 30
---------------------------------------------------------------------Choose the
invalid declaration of String array?

A) String[] s
B) String s[]
C) Stirng [s]
D) String []s
---------------------------------------------------------------------QUESTION 31
----------------------------------------------------------------------

What is the output of below code,


File f = new File("c:\\test\\abc.txt");
System.out.println(f.getName());
A) abc
B) abc.txt
C) c:\test\abc.txt
D) compile error
---------------------------------------------------------------------QUESTION 32
--------------------------------------------------------------------public
class ArrayTest { int[] one; int[] two;
@Before
public void first(){one= new int[]{1,2}; two= new int[]{1,2};}
@Test public void test() {
assertArrayEquals(one, two);}
}
What is the result of executing the above JUnit Test?
A) Test fails as references of both the arrays are not equal
B) Test passes
C) Compilation fails as there is no method assertArrayEquals in Junit D) Runtime exception
occurs

---------------------------------------------------------------------QUESTION 33
---------------------------------------------------------------------In the Publish-Subscribe messaging model, the subscribers register themselves in a topic and are
notified when new messages arrive to the topic. Which pattern does most describe this model?

A) Adapter
B) Notifier
C) Observer
D) State

---------------------------------------------------------------------QUESTION 34
---------------------------------------------------------------------When would you use the Singleton design pattern?
A. to limit the class instantiation to one object
B. to provide global access to one instance across the system
C. to ensure that a certain group of related objects are used together
D. to abstract steps of construction of complex objects
A) A
B) A,B
C) A,B,C
D) A,B,D
---------------------------------------------------------------------QUESTION 35
-------------------------------------------------------------------public class ByteTest { public static void main(String[]
args) {
String obj = "abc";
byte b[] =
obj.getBytes();
ByteArrayInputStream obj1 = new ByteArrayInputStream(b);
System.out.println((char)obj1.read());
}
What is the output?
A) a
B) b
C) c
D) abc E) 97

---------------------------------------------------------------------QUESTION 36
---------------------------------------------------------------------What is the output for the below code ?
public class Test { public static void
main(String argv[]){

ArrayList list = new ArrayList();


ArrayList listStr = list;
ArrayList listBuf = list;
listStr.add(0, "Hello");
StringBuffer buff = (StringBuffer) listBuf.get(0);;
System.out.println(buff.toString());
}}
A) Hello
B) Compile time error
C) java.lang.ClassCastException
D) null
---------------------------------------------------------------------QUESTION 37
---------------------------------------------------------------------What is the output for the below code ? public
interface TestInf { int i =10;
} public class Test
{
public static void main(String... args) {
TestInf.i=12;
System.out.println(TestInf.i);
}
}
A) 10
B) 12
C) compile time error
D) run time error
---------------------------------------------------------------------- QUESTION 38
---------------------------------------------------------------------Given the following declarations, which of the assignments given in the options below would
compile. Select the two correct answers. int i = 5; boolean t = true; float f = 2.3F; double d = 2.3;

A. t = (boolean) i;
B. f = d;
C. d = i;
D. i = 5;
E. f = 2.8;
A) A,B,C
B) B,C
C) C,D
D) C,D,E
E) A,D,E
---------------------------------------------------------------------QUESTION 39
---------------------------------------------------------------------What is the output of the below code: public
class Test { public static void main(String...
args) { double
d=2D+2d+2.+2l+2L+2f+2F+2.f+2.D;
System.out.println(d);
}
}
A) 18
B) 9
C) 9.0
D) Compiler error
E) Run time exception
---------------------------------------------------------------------QUESTION 40
---------------------------------------------------------------------What will be the result of compiling and run the following
code: import java.io.File; public class Test { public static
void main(String... args) throws Exception {
File myDir = new File("test");
// myDir.mkdir();

File myFile = new File(


myFile.createNewFile();

myDir, "test.txt");

}}
A) create directory "test" and a file name as "test.txt
B) java.io.IOException
C) Compile with error
D) None of the above ---------------------------------------------------------------------QUESTION 41
---------------------------------------------------------------------Pick runtime
exception?....
A. Class cast exception
B. File not found exception
C. Nullpointer exception
D. Security exception
E. Above all
A) A,B,C
B) C,D,E
C) A,D,E
D) A,C,D
E) E
---------------------------------------------------------------------QUESTION 42
---------------------------------------------------------------------Given that the current directory is empty, and that the user has read and write
permissions, and the following: 11 . import java.io.*;
12. public class DOS {
13. public static void main(String[] args) {
14. File dir = new File("dir");
15. dir.mkdir();
16. File f1 = new File(dir, "f1.txt");
17. try {
18. f1.createNewFile();
19. } catch (IOException e) { ; }
20. File newDir = new File("newDir");

21. dir.renameTo(newDir);
22. }
23. }
Which statement is true?
A. Compilation fails.
B. The file system has a new empty directory named dir.
C. The file system has a new empty directory named newDir.
D. The file system has a directory named dir, containing a file f1.txt.
E. The file system has a directory named newDir, containing a file f1.txt. A) A
B) B
C) C
D) D E) E

---------------------------------------------------------------------QUESTION 43
---------------------------------------------------------------------What gets printed when the following JSP code is invoked in a browser. Select the one correct
answer.
< %= if(Math.random() < 0.5) % > hello
< %= } else { % >
hi
< %= } % >
A) The browser will print either hello or hi based upon the return value of random.
B) The string hello will always get printed.
C) The string hi will always get printed.
D) The JSP file will not compile.
---------------------------------------------------------------------QUESTION 44
---------------------------------------------------------------------What gets printed when the following code in a JSP is executed
< % int y = 0; % >
< % int z = 0; % >
< % for(int x=0;x<3;x++) { % >

< % z--;++y;% >


< % }% >
< % if(z<y) {% >
< %= z% >
< % } else {% >
< %= z - 1% >
< % }% >
A) 3
B) -1 C)
2
D) -3
E) generates compilation error
---------------------------------------------------------------------QUESTION 45
---------------------------------------------------------------------Which of the following is the correct location of compiled class files within a war file?
1)

/META-INF/classes

2)

/WEB-INF/bin

3)

/WEB-INF/bin/classes

4)

/WEB-INF/classes

5)

/contextroot/classes

A) 1
B) 2
C) 3
D) 4
E) 5
---------------------------------------------------------------------QUESTION 46
---------------------------------------------------------------------Consider the below form in a HTML page. The Servlet has to add 1 marks to a variable 'marks', if
the student selects JAVA in the form. Which code below in the Servlets doPost() method will
achieve this?

< form method="post" action="Evaluate" >


<h2>Which language is Platform independent</h2>
<p><input type="radio" name="Q1" value="C"> C </input></p>
<p><input type="radio" name="Q1" value="C++"> C++ </input></p>
<p><input type="radio" name="Q1" value="JAVA"> JAVA </input></p>
<input type="submit" value="Submit">
< /form >
A) if(request.getAttribute("Q1").equals("JAVA")){marks+=1;
}
B) if(request.getParameter("Submit").equals("JAVA")){ marks+=1;
C) The form is wrong as you cannot give the same name "Q1" for all three radio buttons D)
if(request.getParameter("Q1").equals("JAVA")){ marks+=1;
}
---------------------------------------------------------------------QUESTION 47
---------------------------------------------------------------------Which numbers gets printed when the following JSTL code fragment is executed? Select the
correct answer.

< %@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" % >


< c:set var="j" value="4,3,2,1"/ >
< c:forEach items="${j}" var="item" begin="1" end="2" varStatus="status" >
< c:out value="${status.count}" default="abc"/ >
< /c:forEach >
A. 1
B. 2
C. 3
D. 4
E. The program does not compile.
A) A,B
B) B,C
C) A,C
D) D,E
E) C,D,E

---------------------------------------------------------------------QUESTION 48
---------------------------------------------------------------------Which of the following uri needs to be declared in taglib directive of a JSP, if you need to use the
setTimeZone tag?

A) http://java.sun.com/jsp/jstl/fmt
B) http://java.sun.com/jsp/jstl/sql
C) http://java.sun.com/jsp/jstl/xml
D) http://java.sun.com/jsp/jstl/core
---------------------------------------------------------------------QUESTION 49
---------------------------------------------------------------------What gets printed when the following expression is evaluated? Select the one correct answer.
${"5" + "4"+6+8}

A) 5414
B) 5468
C) 23
D) 518
---------------------------------------------------------------------QUESTION 50
---------------------------------------------------------------------What gets printed when the following JSTL code fragment is executed? Select the one correct
answer.
< %@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" % >
< c:set var="item" value="2"/ >
< c:forEach var="item" begin="0" end="0" step="2" >
< c:out value="" default="abc"/ >
< /c:forEach >
A) The JSTL code does not compile as an attribute for forEach tag is not correct.
B) 0

C) 2
D) ABC
E) Nothing gets printed.
---------------------------------------------------------------------QUESTION 51
---------------------------------------------------------------------What is the output of the below code:
< %@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" % >
< c:forEach var="item" begin="0" end="9" step="2" >
${item}
< /c:forEach >
A) 1 2 3 4 5 6 7 8 9
B) 1 3 5 7 9
C) 0 2 4 6 8
D) 0 2 4 6 8 9
---------------------------------------------------------------------QUESTION 52
---------------------------------------------------------------------A JSP file that uses a tag library must declare the tag library first. The tag library is defined using
the taglib directive <%@= taglib uri="..." prefix="..."%>
Which of the following specifies the correct purpose of prefix attribute. Select the one correct
answer.
1. The prefix defines the name of the tag that may be used for a tag library.
2. The prefix attribute defines the location of the tag library descriptor file.
3. The prefix attribute should refer to the short name attribute of the tag library file that is defined
by the uri attribute of taglib directive.
4. The prefix must be defined in the taglib directive and used in front of the tagname of a tag
A) 1
B) 2
C) 3
D) 4

---------------------------------------------------------------------QUESTION 53
---------------------------------------------------------------------Choose the incorrect statement about SingleThreadModel.
A. It is used to ensure that servlet can handle only one request at a time.
B. It is a marker interface
C. It solves all the thread-safety issues
A) A
B) B
C) C
---------------------------------------------------------------------QUESTION 54
---------------------------------------------------------------------Which of the following are the session tracking techniques?
A. URL rewriting, using HttpSession object, using response object, using hidden fields
B. URL rewriting, using HttpSession object, using cookies, using hidden fields
C. URL rewriting, using servlet object, using response object, using cookies
D. URL rewriting, using request object, using response object, using session object
A) A
B) B
---------------------------------------------------------------------

C) C
D) D

QUESTION 55
What is the output of the below code:
< %@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" % >
< c:set var="j" value="4,3,2,1"/ >
< c:forEach items="${j}" var="item" varStatus="status" >
< c:if test="${status.first}" >
< c:out value="${status.index}" default="abc"/ >
< /c:if >
< /c:forEach >
A) 0
B) 1
C) 2
D) 3
E) code does not compile
---------------------------------------------------------------------QUESTION 56
---------------------------------------------------------------------The life cycle of a servlet is managed by
A) JSP Engine
B) servlet container
C) WebServer
D) EJB Container
---------------------------------------------------------------------- QUESTION 57
---------------------------------------------------------------------A user types the URL http://www.manipalglobal.com/ibm/index.html . Which HTTP request gets
generated. Choose the correct answer
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

A) GET method
B) POST method
C) HEAD method
D) PUT method
---------------------------------------------------------------------QUESTION 58
---------------------------------------------------------------------Which of the following pattern works as a bridge between two incompatible interfaces.?
A) Builder Pattern
B) Adapter Pattern
C) Prototype pattern
D) Bridge Pattern
---------------------------------------------------------------------QUESTION 59
---------------------------------------------------------------------Which Design Pattern provides a way to access the elements of an aggregate object
sequentially without exposing its underlying representation.

A) Iterator
B) Command
C) Observer
D) Strategy

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

---------------------------------------------------------------------QUESTION 60
---------------------------------------------------------------------How is an abstract class represented in a class diagram?
A) Class Name is Underlined
B) Class Name is in Italics
C) Class Name is in Bold
D) Class Name is in uppercase
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

---------------------------------------------------------------------

------------------------------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------QUESTION 1
How is an abstract class represented in a class diagram?
A) Class Name is Underlined
B) Class Name is in Italics
C) Class Name is in Bold
---------------------------------------------------------------------

--------------------------------------------------------------------D) Class Name is in uppercase


---------------------------------------------------------------------QUESTION 2
---------------------------------------------------------------------You want to create families of related objects, to be used interchangeably to configure you
application. What is the most appropriate pattern to use?
A) Factory
B) Builder
C) Abstract Factory
D) Composite
---------------------------------------------------------------------QUESTION 3
---------------------------------------------------------------------1 ..* can be defined as_____________
A) No limit on the number of instances (including none).
B) Zero or one instance. The notation.
C) Exactly one instance
D) At least one instance
---------------------------------------------------------------------QUESTION 4
---------------------------------------------------------------------In a Sequence diagram, Slanted lines describe _____________
A) Construction of objects
B) Destruction of object
C) Propogation delay of messages
D) order of messages
E) race conditions
QUESTION 5

---------------------------------------------------------------------

--------------------------------------------------------------------In Junit @Rule


TestName is invoked when ___________
A) to mark public fields of a test class
B) test is about to start
C) test method is running.
D) All of the above
---------------------------------------------------------------------QUESTION 6
---------------------------------------------------------------------Which of the following pattern works as a bridge between two incompatible interfaces.?
A) Builder Pattern
B) Adapter Pattern
C) Prototype pattern
D) Filter Pattern
---------------------------------------------------------------------QUESTION 7
---------------------------------------------------------------------What is an actor model?
A) An actor model can represent an external entity which communicates with the system
B) An actor can represent a specific physical entity
C) An Actor model can represent a role played by the User.
D) All of the above
---------------------------------------------------------------------QUESTION 8
---------------------------------------------------------------------Which Is the suitable webcomponent to perform tasks like authentication, data
compression, logging and auditing?
A) Filter
---------------------------------------------------------------------

--------------------------------------------------------------------B) Servlet
C) JSP
D) servlet container
QUESTION 9
What is the output of the below code:
@WebServlet("/DemoServlet") public class DemoServlet extends HttpServlet { protected
void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
}
}
A) No Ouput after execution
B) Infinite Loop
C) Compilation error
D) Runtime error
---------------------------------------------------------------------QUESTION 10
---------------------------------------------------------------------What is the output of the below code:
@WebServlet("/DemoServlet") public class DemoServlet extends HttpServlet { protected
void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException { doPost(request,response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException { doGet(request,response);
}
}
A) No Output after execution
B) Infinite loop causing "StackOverFlowError"
C) Compilation error
D) None of the above
---------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------------------------QUESTION 11

---------------------------------------------------------------------

The ......................... method executes an SQL statement that may return multiple results.
A) executeUpdate()
B) executeQuery()
C) execute()
D) noexecute()
---------------------------------------------------------------------QUESTION 12
---------------------------------------------------------------------What is the output of the below code: public
class Test {
public static void main(String[] args){
System.out.println(Thread.currentThread().getName());
}
}
A) mainthread
B) Thread
C) main
D) currentThread
---------------------------------------------------------------------QUESTION 13
-------------------------------------------------------------------public class Test { public static void main(String args[])
{
try {
int a = args.length;
int b = 10 / a;
System.out.print(a);
try {
== 1)
a - a;
{
c[] = {1};
= 9;

if (a
a=a/
if (a == 2)
int
c[8]

}
}
catch (ArrayIndexOutOfBoundsException e) {
System.out.println("TypeA");
---------------------------------------------------------------------

}
}
catch (ArithmeticException e) {
System.out.println("TypeB");
}
}
}
A) TypeA
B) 0TypeA
C) 0TypeB
D) TypeB
---------------------------------------------------------------------QUESTION 14
---------------------------------------------------------------------What is the output of the below code:
public class Test { public static void
main(String[] args) { double x =
0, y = 5.4324;
try {
System.out.println( (y/x) );
}
catch (Exception e) {
System.out.println("Exception");
}
catch (Throwable t) {
System.out.println("Error");
}}}
A) Exception
B) Error
C) Infinity
D) Exception Error
---------------------------------------------------------------------- QUESTION 15
---------------------------------------------------------------------Choose the
invalid declaration of String array?
---------------------------------------------------------------------

A) String[] s
B) String s[]
C) Stirng [s]
D) String []s
---------------------------------------------------------------------QUESTION 16
--------------------------------------------------------------------public
class ArrayTest { int[] one; int[] two;
@Before
public void first(){one= new int[]{1,2}; two= new int[]{1,2};}
@Test public void test() {
assertArrayEquals(one, two);}
}
What is the result of executing the above JUnit Test?
A) Test fails as references of both the arrays are not equal
B) Test passes
C) Compilation fails as there is no method assertArrayEquals in Junit
D) Runtime exception occurs
---------------------------------------------------------------------QUESTION 17
-------------------------------------------------------------------public class ByteTest { public static void main(String[]
args) {
String obj = "abc";
byte b[] =
obj.getBytes();
ByteArrayInputStream obj1 = new ByteArrayInputStream(b);
System.out.println((char)obj1.read());
}
What is the output?
A) a
B) b
C) c
D) abc
---------------------------------------------------------------------

E) 97
---------------------------------------------------------------------QUESTION 18
---------------------------------------------------------------------What is the output of the below code:
class Test{ public static void
main(String[] args) { new
Thread(new Runnable() {
@Override
public void run() {
System.out.println("Thread running");
}
}).start();
}
}
A) Thread running
B) No output
C) Compilation error
D) Runtime error
---------------------------------------------------------------------QUESTION 19
---------------------------------------------------------------------What is the output of the below code:
class Test extends Thread{ public static
void main(String[] args) {
Test t = new Test();
t.setName("Thread 0");
t.start();
}
public void run(){
System.out.println(Thread.currentThread().getName());
}
}
A) Thread 0
B) main
---------------------------------------------------------------------

Thread 0
C) Compilation error
D) Runtime error
---------------------------------------------------------------------QUESTION 20 ---------------------------------------------------------------------- Which
Interface does not contain setAttribute() and getAttribute()?

A) ServletConfig
B) ServletContext
C) HttpRequest
D) HttpSession
---------------------------------------------------------------------QUESTION 21
---------------------------------------------------------------------Which methods belong to Thread Class
a. wait()
b. run()
c. start()
d. notify
e. notifyAll()
f. interrupt()
A) a,b,d
B) c,d,e,f
C) b,c,f
D) b,d,e,f
---------------------------------------------------------------------QUESTION 22
---------------------------------------------------------------------Match the Following:
a. components : 1) Dashed Arrows
b. Dependencies : 2)rectangles with two tabs at the upper left.
C . Component : 3)Circle and solid line

---------------------------------------------------------------------

A) a3 b1 c-2 B)
a-2 b1 c3
C) a1
b-2 c3 D)
a2 b3 c-1
---------------------------------------------------------------------QUESTION 23
---------------------------------------------------------------------How to represent an instance in a UML diagram
A) underline
B) slanted line
C) overline
D) Dashed line
---------------------------------------------------------------------QUESTION 24
---------------------------------------------------------------------What happens if you call deleteRow() on a ResultSet object?
[A] The row you are positioned on is deleted from the ResultSet, but not from the database.
[B] The row you are positioned on is deleted from the ResultSet and from the database
[C] The result depends on whether the property synchronizeWithDataSource is set to true or false
[ D] You will get a compile error: the method does not exist because you can not delete rows
from a ResultSet
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 25
---------------------------------------------------------------------Whats is the output of the below code:
class Test extends Thread{ public
---------------------------------------------------------------------

static void main(String[] args) { Vector


v = new Vector(3,2); v.add("data 1");
v.add("data 2");
v.add("data 3");
v.removeAll(v);
System.out.println(v.isEmpty());
}
}
A) true
B) false
C) comiplation fails
D) Runtime error
---------------------------------------------------------------------QUESTION 26
---------------------------------------------------------------------What is the ouput of the below code:
import java.io.*; class files {
public static void main(String args[]) {
File obj = new File("/FilesDemo/DemoPrograms");
System.out.print(obj.getAbsolutePath());
}
}
A) FilesDemo/DemoPrograms
B) /FilesDemo/DemoPrograms/
C) /FilesDemo/DemoPrograms
D) Compilation fails
---------------------------------------------------------------------QUESTION 27
---------------------------------------------------------------------- What is the output of the below code:
class Test { public static void main(String[]
args) {
try {
Myclass object1 = new Myclass("Hello", -7, 2.1e10);
FileOutputStream fos = new FileOutputStream("serial");
ObjectOutputStream oos = new ObjectOutputStream(fos);
---------------------------------------------------------------------

oos.writeObject(object1);

oos.flush();

oos.close();

}
catch(Exception e) {
System.out.println("Serialization" + e);
System.exit(0);
}
try
int x;

FileInputStream fis = new FileInputStream("serial");


ObjectInputStream ois = new ObjectInputStream(fis);
= ois.readInt();
ois.close();

System.out.println(x);
}
catch (Exception e) {
System.out.print("deserialization");
System.exit(0);
}
}
}
class Myclass implements Serializable {
String s;
int i;
double d;
Myclass(String s, int i, double d){
this.d = d; this.i = i; this.s = s;
}
}
A) -7
B) Hello
C) 2.10E10
D) deserialization
---------------------------------------------------------------------QUESTION 28
---------------------------------------------------------------------Which two of the following statements are true?
a)The doFilter method is always invoked by the container, never within a programmers code
b)A filter can be invoked either through being declared in WEB.XML or explicitly within
---------------------------------------------------------------------

aprogrammers code
c)Filters are associated with a URL via the filter-mapping tag
d)Filters can be initialised via the filter-init-param tag in the deployment descriptor
e)Filters can be initialised via the init-param tag in the deployment descriptor
A) c,e
B) d,e C)
b,e
D) a,e
---------------------------------------------------------------------QUESTION 29
---------------------------------------------------------------------Which three of the following are true about servlet filters? a)A
filter must implement the destroy method
b)

A filter must implement the do Filter method

c)

A servlet may have multiple filters associated with it

d)

A servlet that is to have a filter applied to it must implement the javax.servlet.FilterChain


interface

e)

A filter that is part of a filter chain passes control to the next filter in the chain by invoking
theFilterChain forward method

A) a,b,c
B) c,d,e
C) b,d,e
D) a,d,e
---------------------------------------------------------------------QUESTION 30
---------------------------------------------------------------------How many numbers gets printed when the following JSTL code fragment is executed? Select the
one correct answer.
< %@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" % >
< c:set var="item" value="2"/ >
< c:choose >
< c:when test="${item greaterThan 0}" >
< c:out value="1"/ >
< /c:when >
---------------------------------------------------------------------

< c:when test="${item==2}" >


< c:out value="2"/ >
< /c:when >
< c:otherwise >
< c:out value="4"/ >
< /c:otherwise >
< /c:choose >
A) No
num
ber
gets
print
ed.
B) 1 C)
2
D) 3
E) Error at the Ouput
---------------------------------------------------------------------QUESTION 31
---------------------------------------------------------------------What gets printed when the following expression is evaluated? Select the one correct
answer.${4 div 5} a. 0 b. 0.8
c. 1
d. -1
A) a
B) b
C) c
D) d
---------------------------------------------------------------------QUESTION 32
---------------------------------------------------------------------Seperater used to segregate from the url and parameter values while calling the get() from the
html form?
A) *
B) #
---------------------------------------------------------------------

C) ?
D) :
---------------------------------------------------------------------QUESTION 33
---------------------------------------------------------------------What are the attribute names to be specified for the tag below
< %@ taglib __________="http://java.sun.com/jsp/jstl/core" _______="c" % >
A) url,uri
B) uri,suffix
C) uri,prefix
D) None of the above
---------------------------------------------------------------------QUESTION 34
-------------------------------------------------------------------public class Test { public static void main(String[]
args) { try{
System.out.println("String "+1/0);
}catch(ArithmeticException ae){
System.out.println("Catch block");
}
}
}
What is the output of the program?
A) String Infinity Catch block
B) String Catch block
C) Catch block
D) Infinity
---------------------------------------------------------------------QUESTION 35
---------------------------------------------------------------------public class
Test {
public static void main(String[] args) {
---------------------------------------------------------------------

String a = "hello i love java";


System.out.println(a.indexOf('i')+" "+a.lastIndexOf('o')+" "+a.lastIndexOf('i')+" "+ a.indexOf('o'));
}
}
What is the ouput of the program?
A) 6 9 6 7
B) 6 9 6 4
C) 5 9 6 4
D) 5 9 5 4
---------------------------------------------------------------------QUESTION 36
---------------------------------------------------------------------Write the valid code to get the month? public
class Test {
public static void main(String[] args) {
Calendar calendar = new GregorianCalendar();
//insert code here
System.out.println(month);
}
}
A) int month

= calendar.get(Calendar.DAY_OF_MONTH);

B) int month

= calendar.get(Calendar.MONTH);

C) int month

= calendar.get(MONTH);

D) int month

= calendar.get(MONTH);

---------------------------------------------------------------------QUESTION 37
---------------------------------------------------------------------What is the output of the below code: public
class Test {
public static void main(String[] args) {
List<String> list = new ArrayList();
list.add("test");
list.add(123);
list.add('c');
System.out.println(list);
}
---------------------------------------------------------------------

}
A) [test,123,c]
B) No output
C) compilation fails
D) Runtime error
---------------------------------------------------------------------QUESTION 38
---------------------------------------------------------------------What happens if you call the method close() on a ResultSet object?
[A] the method close() does not exist for a ResultSet. Only Connections can be closed.
[B] the database and JDBC resources are released
[C] you will get a SQLException, because only Statement objects can close ResultSets
[D] the ResultSet, together with the Statement which created it and the Connection from which the
Statement was retrieved, will be closed and release all database and JDBC resources
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 39
---------------------------------------------------------------------public class
Test {
public static void main(String[] args) throws SQLException, ClassNotFoundException {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn =
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","HR","HR");
Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = st.executeQuery("SELECT * FROM
survey");
rs.absolute(5);
rs.close();
st.close();
---------------------------------------------------------------------

conn.close();

}}
Why do we use rs.absolute(5) in the above program?
A) Move cursor to the fifth-to-last row
B) Move cursor to the fifth row
C) Compilation fails
D) runtime error
---------------------------------------------------------------------QUESTION 40
---------------------------------------------------------------------Choose the correct one to import a entire package
A) import package
B) import package*;
C) import package.*;
D) import package.*.;
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 41
---------------------------------------------------------------------Given:
class Mammal { }
extends Mammal {
new Mammal();

class Raccoon
Mammal m =

}
class BabyRaccoon extends Mammal { }
Which four statements are true? (Choose four.)
A. Raccoon is-a Mammal.
B. Raccoon has-a Mammal. C. BabyRaccoon is-a Mammal.
D. BabyRaccoon is-a Raccoon.
E. BabyRaccoon has-a Mammal.
F. BabyRaccoon is-a BabyRaccoon.
---------------------------------------------------------------------

A) A,B,D,C
B) C,D,E,A
C) A,D,E,F
D) A,B,C,F
---------------------------------------------------------------------QUESTION 42
---------------------------------------------------------------------Given the declaration
Circle x = new Circle(), which of the following statement is most accurate. A.
x contains an int value.
B. x contains an object of the Circle type.
C. x contains a reference to a Circle object.
D. You can assign an int value to x.
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 43
---------------------------------------------------------------------Reaarrange the steps in a correct order to connect to the database?
A. Executing the ResultSet
B. Connecting to database
C. Executing the SQL Query
D. Registering the driver
A) C--->B--->D---->A
B) C--->A--->B---->A
C) D--->B--->C---->A
D) B--->D--->C---->A
---------------------------------------------------------------------QUESTION 44
------------------------------------------------------------------------------------------------------------------------------------------

What is the ouput of the below code:class Test


{ public static void main(String[]
s)
{
String s1="Hello",s2="World";
System.out.println(s1+s2);
System.out.println(s1.concat(s2);
}
}
A) HelloWorld
B) HelloWorld
HelloWorld
C) Compilation fails
D) Runtime error
---------------------------------------------------------------------QUESTION 45
---------------------------------------------------------------------Which of the following pattern works as a bridge between two incompatible interfaces?
A - Builder Pattern
B - Adapter Pattern
C - Prototype Pattern
D - Filter Pattern
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 46
------------------------------------------------------------------------------------------------------------------------------------------

Which design pattern you would you use to decouple the creation procedure of a complex
object from it's concrete instance to be able to apply that procedure on variety of
implementations.
A) Factory builder design pattern
B) Method Builder design pattern
C) Builder design pattern
D) Factory method design pattern
---------------------------------------------------------------------QUESTION 47
---------------------------------------------------------------------What will be the output of the below
code: if( "Welcome".trim() ==
"Welcome".trim() )
System.out.println("Equal"); else
System.out.println("Not Equal");
A) compile and display Equal
B) compile and display Not Equal
C) cause a compiler error
D) compile and display NULL
---------------------------------------------------------------------QUESTION 48
---------------------------------------------------------------------The performance of the application will be faster if you use PreparedStatement interface because
query is compiled only once?
A) true
B) false
---------------------------------------------------------------------QUESTION 49
---------------------------------------------------------------------Which isolation level prevents dirty read in JDBC, connection class.
A) TRANSACTION_READ_UNCOMMITTED
B) TRANSACTION_READ_ COMMITTED
C) TRANSACTION_SERIALIZABLE
---------------------------------------------------------------------

D) TRANSACTION_REPEATABLE_READ
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 50
---------------------------------------------------------------------Which Is the suitable webcomponent to perform tasks like authentication, data compression,
logging and auditing?
A) Filter
B) Servlet
C) JSP
D) servlet container
---------------------------------------------------------------------QUESTION 51
---------------------------------------------------------------------Which of the following statement is true about servlet filter ?
A)A filter is a reusable piece of code that can transform the content of HTTP requests, responses
and header information.
B)Filters do not generally create a response or respond to a request as servlets do.
C)Filters can act on dynamic or static content.
D)All of the above
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 52
---------------------------------------------------------------------A programmer has an algorithm that requires a java.util.List that provides an efficient
implementation of add(0, object), but does NOT need to support quick random access.
What supports these requirements?
---------------------------------------------------------------------

A. java.util.Queue
B. java.util.ArrayList
C. java.util.LinearList
D. java.util.LinkedList
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 53
---------------------------------------------------------------------What is the output of the below code: class
Test{
public static void main(String[] args) {
Thread t = new Thread();
System.out.println(t.currentThread());
}
}
A) 1
B) 3
C) 5
D) 7
---------------------------------------------------------------------QUESTION 54
---------------------------------------------------------------------Given:
34. HashMap props = new HashMap();
35. props.put("key45", "some value");
36. props.put("key12", "some other value");
37. props.put("key39", "yet another value");
38. Set s = props.keySet();
39. // insert code here What, inserted at line 39, will sort the keys in the props
HashMap?
---------------------------------------------------------------------

A. Arrays.sort(s);
B. s = new TreeSet(s);
C. Collections.sort(s);
D. s = new SortedSet(s);
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 55
---------------------------------------------------------------------Which of these is a correct example of specifying a listener element resented by MyClass class.
Assume myServlet element is defined correctly. Select the one correct answer.
A. <listener>MyClass</listener>
B. <listener> <listener-class>MyClass</listener-class></listener>
C. <listener> <listener-name>aListener</listener-name> <listener-class>MyClass</listener-class>
< /listener >
D. <listener> <servlet-name>myServlet</servlet-name> <listener-class>MyClass</listener-class>
< /listener >
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 56
---------------------------------------------------------------------Which result set generally does not show changes to the underlying database that are made while
it is open. The membership, order, and column values of rows are typically fixed when the result
set is created?
A) TYPE_FORWARD_ONLY
B) TYPE_SCROLL_INSENSITIVE
C) TYPE_SCROLL_SENSITIVE
D) ALL MENTIONED ABOVE
---------------------------------------------------------------------

---------------------------------------------------------------------QUESTION 57
---------------------------------------------------------------------Choose the correct one to import a entire package
A) import package
B) import package*;
C) import package.*;
D) import package.*.;
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 58
---------------------------------------------------------------------What is the ouput of the below code:
class Test { public static void main(String
args[])
{
StringBuffer s1 = new StringBuffer("Hello");
StringBuffer s2 = s1.reverse();
System.out.println(s2);
}
}
A) Hello
B) olleH
C) Compilation fails
D) Runtime error
---------------------------------------------------------------------QUESTION 59
---------------------------------------------------------------------It is known as Action or Transaction and is used to encapsulate a request as an object to
support rollback, logging, or transaction functionality

---------------------------------------------------------------------

A) Chain of Responsibility Pattern


B) Command Pattern
C) Observer Pattern
D) Strategy Pattern
---------------------------------------------------------------------QUESTION 60
---------------------------------------------------------------------Which is the object allows to access the sendRedirect()?
A) request
B) response
C) session
D) context
---------------------------------------------------------------------QUESTION 61
---------------------------------------------------------------------What gets printed when the following expression is evaluated? Select the one correct
answer.${12 % 4}
A) 0
B) 3
C) 8
D) 16
---------------------------------------------------------------------QUESTION 62
---------------------------------------------------------------------ResultSet is Updatable by default(true or false)
A) true
B) false
---------------------------------------------------------------------QUESTION 63
------------------------------------------------------------------------------------------------------------------------------------------

What is the output of the below code?


class Test{
public static void main(String[] args) {
Object obj = new Object();
System.out.println(obj.getClass());
}
}
A) class java.lang.Test
B) class java.lang.Object
C) java.lang.Object
D) java.lang.Test
---------------------------------------------------------------------QUESTION 64
---------------------------------------------------------------------class
Base {}
class Derived extends Base { public
static void main(String args[]){
Base
a = new Derived();
System.out.println(a instanceof Derived);
}
}
A) true
B) false
---------------------------------------------------------------------QUESTION 65
---------------------------------------------------------------------What is the output of the below code? public
class Test { public static void main(String[] args)
{ List<Integer> list = new
ArrayList<Integer>(); list.add(9); list.add(8); list.add(2);
list.add(5); list.add(1);
Iterator itr = list.iterator();
Collections.reverse(list);
Collections.sort(list); while(itr.hasNext()){
System.out.println(itr.next());
}
---------------------------------------------------------------------

}
}
A) 9
8
2
5
1 B)
1
5
2
8
9
C) 1
2
5
8
9
D) 1
2
9
8
5
---------------------------------------------------------------------QUESTION 66
---------------------------------------------------------------------What is the output of the below code: class
Test { public static void main(String args[])
{
int array[] = new int [5];
for (int i =
5; i > 0; i--)
array[5 - i] = i;
Arrays.sort(array);
System.out.print(Arrays.binarySearch(array, 4));
}
}
A) 1
B) 1
---------------------------------------------------------------------

C) 2
D) 3
---------------------------------------------------------------------QUESTION 67
---------------------------------------------------------------------Which design pattern you would you use to limit the class instantiation to one object?
A) Builder design pattern
B) Factory Method Design Pattern
C) Prototype design pattern
D) Singleton design pattern
---------------------------------------------------------------------QUESTION 68
---------------------------------------------------------------------What are the consequences of applying the abstract factory pattern?
A. it will be much easier to introduce new family of products
B. it makes it easier for a certain family of objects to work together
C. it makes it easier for the client to deal with tree-structured data
D. it makes the designed product families exchangeable
A) A,C
B) C,D
C) B,D
D) D,A
---------------------------------------------------------------------QUESTION 69
---------------------------------------------------------------------Name the servlet interface which consist of destroy and intializer methods
A) javax.servlet.http.HttpServlet
B) javax.servlet.GenericServlet
C) javax.servlet.http.HttpServletRequest
D) javax.servlet.http.HttpServletResponse

---------------------------------------------------------------------

---------------------------------------------------------------------QUESTION 70
-------------------------------------------------------------------int[] x = {3,4,5,6};
int[] y = x;
y[2] = 7; What
is the vallue of x[2]=?
A) 4
B) 5
C) 6
D) 7
---------------------------------------------------------------------QUESTION 71
---------------------------------------------------------------------When using HTML forms which of the folowing is true for POST method? Select the one correct
answer.
A. POST allows users to bookmark URLs with parameters.
B. The POST method should not be used when large amount of data needs to be transferred.
C. POST allows secure data transmission over the http method.
D. POST method sends data in the body of the request.
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 72
---------------------------------------------------------------------Steps for creating a Custom tag(Re-arrange)
A. Package Tag Handlers and TLD file into tag library
B. Write TLD file
C. Write Tag Handlers
D. Reference the TLD in the web-app deployment descriptor
A) A,B,D,C
B) D,C,B,A
---------------------------------------------------------------------

C) B,C,A,D
D) A,C,D,B,
---------------------------------------------------------------------QUESTION 73
---------------------------------------------------------------------A team of programmer is involved in reviewing a proposed design for a new utility class. After
some discussion, they realize that the current design allows other classes to access methods in
the utility class that should be accessible only to methods within the utility class itself.
What design issue has the team discovered?
A) Tight Coupling
B) Low cohesion
C) Loose Coupling
D) Weak Encapsulation
---------------------------------------------------------------------QUESTION 74
---------------------------------------------------------------------If in test.jsp \${3+21}
: ${3+2-1} What is
the output?
A) ${3+2-1} : 4
B) \${3+2-1} : 4
C) \${4} : 4
D) ${4} : 4
---------------------------------------------------------------------QUESTION 75
---------------------------------------------------------------------Iterator Pattern is a type of _______________
A) Creational Patterns
B) Behavioral Patterns
C) Structural Patterns
---------------------------------------------------------------------QUESTION 76
---------------------------------------------------------------------

---------------------------------------------------------------------What will be the output of the program? class


MyThread extends Thread{
MyThread(){}
MyThread(Runnable
r){ super();} public void
run(){
System.out.println("Inside Thread");
}}
class MyRunnable implements Runnable{ public
void run(){
System.out.println("Inside Runnable");
}}
class Test{ public static void main(String[]
args){ new MyThread().start(); new
MyThread(new MyRunnable()).start();
}
}
A) Inside Thread
Inside Thread
B) Inside Thread
Inside Runnable
C) Does Not compile
D) Throw Exception at runtime
---------------------------------------------------------------------QUESTION 77
---------------------------------------------------------------------- 05 .
Given :
1. import java.util.*
2. public class WrappedString {
3. private String s
4. public WrappedString(String s) { this.s = s }
5. public static void main(String[] args) {
6. HashSet hs = new HashSet ()
7. WrappedString ws1 = new WrappedString("aardvark" )
8. WrappedString ws2 = new WrappedString("aardvark" )
9. String s1 = new String("aardvark" )
---------------------------------------------------------------------

10. String s2 = new String("aardvark" )


11. hs.add(ws1) hs.add(ws2) hs.add(s1) hs.add(s 2)
12. System.out.println(hs.size()) } } What is the result?
A) 1
B) 2
C) 3
D) 4
---------------------------------------------------------------------QUESTION 78
---------------------------------------------------------------------What is the output for the below code ?
import java.util.LinkedList;
import java.util.Queue; public
class Test {
public static void main(String... args) {
Queue q = new LinkedList();
q.add("newyork");
q.add("ca");
q.add("texas");
show(q);
}
public static void show(Queue q) {
q.add(new Integer(11));
while
(!q.isEmpty ( ) )
System.out.print(q.poll() + " ");
}
}
A) newyork ca texas 11
B) ca newyork texas 11
C) 11 texas ca newyork
D) Compile error : Integer can't add
---------------------------------------------------------------------QUESTION 79
---------------------------------------------------------------------class SuperClass {
---------------------------------------------------------------------

public int doIt(String str, Integer... data)throws ArrayIndexOutOfBoundsException{


String signature = "(String, Integer[])";
System.out.println(str + " " + signature); return
1;
}}
public class Test extends SuperClass{ public int
doIt(String str, Integer... data) throws Exception
{
String signature = "(String, Integer[])";
System.out.println("Overridden: " + str + " " + signature); return
0;
}
public static void main(String... args)
{
SuperClass sb = new Test();
try{
sb.doIt("hello", 3);
}catch(Exception e){
}
}
}
What is the output of the above code?
A) Overridden:hello(String, Integer[])
B) hello (String, Integer[])
C) This code throws exception at run time
D) compile time error
---------------------------------------------------------------------QUESTION 80
---------------------------------------------------------------------Which of the following values can be replaced in the place of 1 and 2 below Statement stmt=
con.createStatement(1,2);
a) ResultSet. TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY
b) ResultSet. TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE
c) ResultSet. CONCUR_UPDATABLE, ResultSet. TYPE_SCROLL_SENSITIVE
d) ResultSet.CONCUR_UPDATABLE, ResultSet. TYPE_FORWARD_ONLY
A) a
---------------------------------------------------------------------

B) b
C) c
D) d
---------------------------------------------------------------------QUESTION 1
--------------------------------------------------------------------What
is the output of the following code? public class Simple{
public static void main(String[] args){
int arr[] = new int[3];

for(int i = 0;i

<=arr.length;i++){
System.out.print(arr[i]);
}
}
}
A) Compilation Error
B) 0 0 0
C) 0 1 2
D) ArrayIndexOutOfBoundsException
---------------------------------------------------------------------QUESTION 2
---------------------------------------------------------------------Which of
the following array declarations are valid?

1) int a[]=new int[];


2) int a[][]=new int[][] ;
3) int a[][]=new int[4][];
4) int a[4]=new int[4];
5) int [] a={1,2,3};
A) 1,2,4
B) 3,5
C) 1,3
D) 1,2,3,4,5

---------------------------------------------------------------------

---------------------------------------------------------------------QUESTION 3
---------------------------------------------------------------------What is the output of the folowing code?
public class Simple{
public static void method(String str)
{
str+=str+2;
System.out.println(str);
}
public static void main(String[] args){
String str="12";

method(str);

System.out.println(str);

}
}
A) 14
14
B) 12122 12122
C) 12122
12
D) 14
12
E) Compilation Error
---------------------------------------------------------------------QUESTION 4
--------------------------------------------------------------------What
is the output of the following? class A
{ int a; static
int b;
A(int a)
{

b=this.a; //Line

this.a=a+b;
}

}
---------------------------------------------------------------------

public class Simple{


main(String[] args){

public static void

System.out.println(new A(6).a); // Line 13


}
}
A) 6
B) 12
C) Compilation error at line 7
D) Compilation error at line 13
---------------------------------------------------------------------QUESTION 5
--------------------------------------------------------------------What
is the output of the following? class Test1
{
static void method(byte a,int b)
{
System.out.println("byte-int");
}
static void method(int a,byte b)
{
System.out.println("int-byte");
}
public static void main(String[] args){
Test1.method(10,20);
}
}
A) byte-int
B) int-byte
C) Compilation Error : No suitable method found D) byte-int int-byte

---------------------------------------------------------------------QUESTION 6
--------------------------------------------------------------------Predict the output : class Vehicle
---------------------------------------------------------------------

int regno;
Vehicle()
{
regno=5;
}
Vehicle(int regno)
{

this();

regno+=this.regno;
}
}
public class Simple{
public static void main(String[] args){
Vehicle v=new Vehicle(7);
System.out.println(v.regno);
}
}
A) Compilation Error
B) 12
C) 7
D) 5
---------------------------------------------------------------------QUESTION 7
---------------------------------------------------------------------Which of the following are valid top level class declarations?
1) public final class A {}
2) protected class A {}
3) abstract final class A {}
4) public static class A {}
A) 1 and 2
B) Only 1
C) 1 and 4
D) 1,2,3,4
---------------------------------------------------------------------

---------------------------------------------------------------------QUESTION 8
---------------------------------------------------------------------- class
Cat
{
Cat(int a)
{
System.out.println("cat");
}
}
class Tiger extends Cat
{
Tiger(int a)
{
super(a);
System.out.println("tiger");
}
}
public class Simple{
public static void main(String[] args){
Cat t=new Tiger(3);
}
}
A) cat
B) cat
tiger C)
tiger
D) Compilation error
---------------------------------------------------------------------QUESTION 9
---------------------------------------------------------------------Predict the
output :
---------------------------------------------------------------------

public class Simple{ public static void


method(Number n) // Line 2
{
if(n instanceof Integer) // Line 4
System.out.println(n); // Line 5
}
public static void main(String[] args){
Number n=new Integer(4); // Line 8
method(n);
// Line 9
}
}
A) 4
B) Compilation error at Line 2
C) Compilation error at line 9
D) Compilation error at line 5
E) Compilation error at line 8 ---------------------------------------------------------------------QUESTION 10
---------------------------------------------------------------------What is
the output of the following ?
public class Simple{
public static void main(String[] args){
String a="Hello";
String b="Hello"; String
c=new String("Hello"); if(a==c)
System.out.println("AC");

if(a==b)

System.out.println("AB");

if(a.equals(c))

System.out.println("AC");

}
}
A) AC
---------------------------------------------------------------------

AB
B) AC AB
AC
C) AB AC
D) AC
E) AB
---------------------------------------------------------------------QUESTION 11
---------------------------------------------------------------------What will be the output of the following JSP code?
< html><body >
< % int a = 10; % >
< %! int a = 20; % >
< %! int b = 30; % >
The value of b multiplied by a is <%= b * a %>
< /body> </html >
A) The value of b multiplied by a is 30
B) The value of b multiplied by a is 300
C) The value of b multiplied by a is 600
D) Compilation Error
---------------------------------------------------------------------QUESTION 12
---------------------------------------------------------------------Which of the following can be used to configure the jsp container to ignore EL expressions?
A) <%@ page isELIgnored="false" %>
B) <%@ include isELIgnored="false" %>
C) <%@ page isELIgnored="true" %>
D) <%@ jsp ELEnabled="false" %>
---------------------------------------------------------------------QUESTION 13
------------------------------------------------------------------------------------------------------------------------------------------

Which of the following are techniquest used for session tracking ?


1) Cookies
2) URL Rewriting
3) Hidden Form Fields
A) 1,2
B) 2,3
C) Only 1
D) 1,2,3
---------------------------------------------------------------------QUESTION 14
---------------------------------------------------------------------Jack has
created the following Servlet listener class .
Public class MyListener implements HttpSessionActivationListener
{
}
Which listener methods he must implement in MyListener class?
A) activateSession() deActivateSession()
B)
sessionCreated() sessionDestroyed()
C) sessionDidActivate()
sessionWillPassivate()
D) sessionInitialized()
sessionInvalidated()

---------------------------------------------------------------------QUESTION 15
---------------------------------------------------------------------Using URL rewriting procedure for session management , every URL on the page must be
encoded using which method?

A) HttpSession.encodeURL()
B) HttpServletRequest.encodeURL()
C) HttpServletResponse.encodeURL()
---------------------------------------------------------------------

D) PageContext.encodeURL();
---------------------------------------------------------------------QUESTION 16
---------------------------------------------------------------------Which of the following entry in web.xml can be used to set the session timeout value to 60
seconds.
A) <session-config>
<session-timeout>60</session-timeout>
< /session-config >
B) <session-config>
<session-timeout>1</session-timeout>
< /session-config >
C) <session-config>
<session-timeout>60 seconds</session-timeout>
< /session-config >
D) <session-config>
<session-timeout>60000</session-timeout>
< /session-config >
---------------------------------------------------------------------QUESTION 17
---------------------------------------------------------------------Which of the following is the correct signature of doFilter() method in Filter interface?
A) public void doFilter(ServletRequest request, ServletResponse response)
B) public void doFilter(FilterChain chain,ServletRequest request, ServletResponse response)
C) public Object doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
D) public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
---------------------------------------------------------------------QUESTION 18
---------------------------------------------------------------------Which of the following diagrams are used in Behavioural modeling of a software system?
A) Class diagram
---------------------------------------------------------------------

B) Object Diagram
C) Activity Diagram
D) All of the above
---------------------------------------------------------------------QUESTION 19
---------------------------------------------------------------------The type of relationship exists between a smartphone and the charger is :
A) Generalization
B) Realization
C) Composition
D) Association
---------------------------------------------------------------------QUESTION 20
---------------------------------------------------------------------Which diagram is used to explain different states of an object during its life time?
A) Object Diagram
B) Class Diagram
C) Sequence Diagram
D) State Chart Diagram
---------------------------------------------------------------------QUESTION 21
---------------------------------------------------------------------What is true about the following code?
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
TestJunit1.class,
TestJunit2.class
}) public class JunitTestSuite
{
}
---------------------------------------------------------------------

A) The code does not run any test as JunitTestSuite class is empty
B) @RunWith is not necessory and can be removed .
C) @Test annotation should be used on the class JunitTestSuite to make the code run correctly.
D) The code runs both the test classes TestJunit1 and TestJunit2 together as a test suite.
---------------------------------------------------------------------QUESTION 22
---------------------------------------------------------------------Which of the following junit assert method asserts that two references refers to the same object?
A) assertThat()
B) assertEqual()
C) assertSame()
D) assertSameReference()
---------------------------------------------------------------------QUESTION 23
---------------------------------------------------------------------What is
the output of the following ?
import java.util.*;
public class Simple{
public static void main(String[] args){
Map<String,Integer> set=new HashMap<String,Integer>();
set.put("A",1); set.put("B",2); set.put("B",3); set.put("C",1);
System.out.println(set);
}
}
A) A=1, B=2, C=1
B) A=1,B=2
C) A=1, B=3, C=1
D) Compilation Error as Duplication values are entered into the map.
---------------------------------------------------------------------QUESTION 24

---------------------------------------------------------------------

---------------------------------------------------------------------Predict the
output of the following code?
import java.util.*;
class Student
{
String name;
Student(String name)
{
this.name=name;
}
}
public class Simple{

public static

void main(String[] args){


Set<Student> set=new TreeSet<Student>();
Student("Saroj")); set.add(new
Student("Vinod"));

set.add(new

set.add(new

Student("Raj")); for(Student s:set)


{
System.out.println(s.name);
}
}
}
A) Saroj Vinod
Raj
B) Raj Saroj
Vinod
C) ClassCastE
xception
D) Compilatio
n Error
---------------------------------------------------------------------QUESTION 25

---------------------------------------------------------------------

---------------------------------------------------------------------Predict the
output of the following:

import java.util.*;

public class Simple{ public static


void main(String[] args){
Queue <Integer>queue=new PriorityQueue<Integer>();
queue.add(1); queue.add(2); queue.add(3); queue.poll();
System.out.println(queue.peek());

}
}
A) 1
B) 2
C) 3
D) Exception
---------------------------------------------------------------------QUESTION 26
---------------------------------------------------------------------What is
the output of the following ?
class A extends Thread implements Runnable // Line 1
{ public void
run()
{
System.out.println("A");
}
}
public class Simple{

public static void

main(String[] args){ A a=new A();


a.start();
---------------------------------------------------------------------

a.run();

// Line 12

}
}
A) A
B) A
A
C) Compilation error at line 1
D) Compilation error at line 12 ---------------------------------------------------------------------QUESTION 27
---------------------------------------------------------------------What is true regarding the following code?
class MyThread implements Runnable
{ public void
run()
{
System.out.println("MyThread");
}
}
public class Simple{
public static void main(String[] args){
MyThread t=new MyThread();
t.start();
}
}
A) Code executes successfully and produces output as "MyThread"
B) Runtime exception
C) Compilation Error on calling method start()
D) Compiles but no output.
---------------------------------------------------------------------QUESTION 28
---------------------------------------------------------------------Which of the following is a type 1 driver
---------------------------------------------------------------------

A) Native API partially Java Driver


B) JDBC ODBC Bridge Driver
C) Net Protocol driver
D) Pure Java Driver
---------------------------------------------------------------------QUESTION 29 ---------------------------------------------------------------------- Following is the code for
calling a stored procedure in JDBC. Fill in the blank with the appropriate call for successfully calling
the stored procedure getEmpName.
String sql = "__________________";
stmt =
conn.prepareCall(sql);
int empID = 102;
stmt.setInt(1, empID);
stmt.registerOutParameter(2,java.sql.Types.VARCHAR);
stmt.execute();

A) {call getEmpName ()}


B) {call getEmpName (?, ?)}
C) {procedure getEmpName (?, ?)}
D) {execute procedure getEmpName (?, ?)}
---------------------------------------------------------------------QUESTION 30
---------------------------------------------------------------------Which of the following is correct way to handle transaction in jdbc?
A) try
{
con.commit();
}
catch(SQLException e)
{ con.rollback(); con.setAutoCommit(false);
}
B) try
{
con.setAutoCommit(false);

con.rollback();
}
catch(SQLException e)
{
con.commit();
---------------------------------------------------------------------

}
C) try
{
con.setAutoCommit(true);

con.commit();
}
catch(SQLException e)
{
con.rollback();
}
D) try
{
con.setAutoCommit(false);

con.commit();
}
catch(SQLException e)
{
con.rollback();
}
---------------------------------------------------------------------QUESTION 31
---------------------------------------------------------------------Which method of jdbc Connection is used to rollback to certain point in your transaction?
A) Connection.rollbackSavepoint()
B) Connection.getSavePoint()
C) Connection.createSavePoint()
D) Connection.setSavepoint()
---------------------------------------------------------------------QUESTION 32
---------------------------------------------------------------------What is the use of the following attribute in a JDBC ResultSet?
ResultSet.CONCUR_UPDATABLE
---------------------------------------------------------------------

A) The resultset can only be read


B) The resultset can only be updatable
C) The resultset can be both read and updated
D) Multiple thread can be able to access the resultset at a time.
---------------------------------------------------------------------QUESTION 33
---------------------------------------------------------------------Which of the JDBC resultset type is used for the following requirement :
The cursor can scroll forward and backward, and the result set is sensitive to changes made by
others to the database that occur after the result set was created.

A) ResultSet.TYPE_FORWARD_ONLY
B) ResultSet.TYPE_SCROLL_SENSITIVE.
C) ResultSet.TYPE_SCROLL_INSENSITIVE
D) ResultSet.TYPE_FORWARD_AND_BACKWARD
---------------------------------------------------------------------QUESTION 34
---------------------------------------------------------------------Which of the transaction isolation level constant in jdbc indicates that : Dirty reads are prevented;
non-repeatable reads and phantom reads can occur.

A) TRANSACTION_SERIALIZABLE
B) TRANSACTION_REPEATABLE_READ
C) TRANSACTION_READ_UNCOMMITTED
D) TRANSACTION_READ_COMMITTED
---------------------------------------------------------------------QUESTION 35
---------------------------------------------------------------------Jack is writing a program in which he needs to write various primitive type values into a file. Which
of the following java io class is best suitable for his requirements?

A) DataOutputStream
B) PrimitiveOutputStream
---------------------------------------------------------------------

C) ObjectOutputStream
D) ByteArrayOutputStream
---------------------------------------------------------------------QUESTION 36
---------------------------------------------------------------------What is the result of the following code when executed in a java program ?
String directory="folder1";
File f1 = new File(directory);
String file="file1.txt";
File f2 = new File(f1, file);
A) File created but Directory not created
B) Directory created but file not created
C) Both file and directory created
D) No file or directory created
---------------------------------------------------------------------QUESTION 37
---------------------------------------------------------------------Which of the following are true about Reader/Writer and InputStream/OutputStream class
hierarchy in java io?

A) The Reader/Writer class hierarchy is character-oriented and the InputStream/OutputStream


class hierarchy is byte-oriented.
B) The Reader/Writer class hierarchy is byte-oriented and the InputStream/OutputStream class
hierarchy is character-oriented.
C) Both Reader/Writer and InputStream/OutputStream class hierarchies are character-oriented
D) Both Reader/Writer and InputStream/OutputStream class hierarchies are byte-oriented
---------------------------------------------------------------------QUESTION 38
---------------------------------------------------------------------What is the output of the following program?
import java.io.*;

class

filesinputoutput {
public static void main(String args[]) {
---------------------------------------------------------------------

InputStream obj = new FileInputStream("inputoutput.java");


System.out.print(obj.available());
}
}
A) true
B) false
C) prints number of bytes in a file
D) prints number of characters in a file
---------------------------------------------------------------------QUESTION 39
---------------------------------------------------------------------What is
the output of the following code?
import java.io.*;
Chararrayinput {

class

public static void main(String[] args) {


String obj = "abcdef";
int length =
obj.length();
char c[] = new char[length];
obj.getChars(0,length,c,0);
CharArrayReader input1 = new CharArrayReader(c);
CharArrayReader input2 = new CharArrayReader(c, 0, 3);
i;
try {
while ((i = input1.read()) != -1) {
System.out.print((char)i);
}
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
A) abc
---------------------------------------------------------------------

int

B) abcd
C) abcde
D) abcdef
---------------------------------------------------------------------QUESTION 40
---------------------------------------------------------------------Which of these method is used to find out that a thread is still running or not?
A) isRunning()
B) isAlive()
C) isDead()
D) run()
---------------------------------------------------------------------QUESTION 41
---------------------------------------------------------------------- What
is the output ?
class A {
int i;

void display()

{
System.out.println(i);
}
}
class B extends A {
int j;

void display()

{
System.out.println(j);
}
}
class inheritance_demo {

public

static void main(String args[])


{
B obj = new B();
obj.j=2;
obj.display();

obj.i=1;

}
---------------------------------------------------------------------

}
A) 0
B) 1
C) 2
D) Compilation error
---------------------------------------------------------------------QUESTION 42
---------------------------------------------------------------------Which of the following statement initiates garbage collection?
A) System.collect()
B) System.gc()
C) System.garbage()
D) System.free()
---------------------------------------------------------------------QUESTION 43
---------------------------------------------------------------------Statement A :
invoking close() on any java.io Streams automatically invokes flush().
Statement B : flush() cannot be called manually through any stream object.

A) A is True and B is False


B) A is False and B is True
C) Both A and B are True
D) Both A and B are False

---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------QUESTION 44
In __________ Design pattern , we create object without exposing the creation logic to the client
and refer to newly created object using a common interface.

A) Singleton
B) Decorator
C) Adaptor
D) Factory
---------------------------------------------------------------------QUESTION 45
---------------------------------------------------------------------Which design pattern does the following code implement?
public class A { private static A
instance = new A(); private A(){}
public static A getInstance(){
return
instance;
}
}
A) Decorator
B) Singleton
C) Factory
D) Observer
E) Bridge
---------------------------------------------------------------------QUESTION 46
---------------------------------------------------------------------The _________ design pattern is used to provide a centralized request handling mechanism so
that all requests will be handled by a single handler.
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------A) front controller


B) factory
C) bridge
D) Observor
E) Singleton
QUESTION 47
Which of the following method of HttpSession Returns the maximum time interval, in seconds, that
the servlet container will keep this session open between client accesses. After this interval, the
servlet container will invalidate the session.

A) setMaxInactiveInterval()
B) getMaxInactiveInterval()
C) getMaxActiveInterval()
D) setMaxActiveInterval()
---------------------------------------------------------------------QUESTION 48
---------------------------------------------------------------------The following code is written in the doGet() method of a servlet.Identify the correct output of the
code.

response.setContentType("text/html");
String site = new String("http://www.mysite.com");
response.setStatus(response.SC_MOVED_TEMPORARILY);
response.setHeader("Location", site);
A) The servlet redirects to the site "http://www.mysite.com"
B) No redirection happens
C) The servlet displays a status code in the output.
D) The servlet outputs the source code of the given web url
------------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------QUESTION 49
---------------------------------------------------------------------Which of the following code in a servlet sets the expiry date of the cookie first_name to 1 day?
A)
Cookie firstName = new Cookie("first_name","mohan");
firstName.setMaxInactiveInterval(60*60*24);
B)
Cookie firstName = new Cookie("first_name","mohan");
firstName.setExpiryDate(60*60*24);
C)

Cookie firstName = new Cookie("first_name","mohan"); firstName.setMaxAge(60*60*24);

D)
Cookie firstName = new Cookie("first_name","mohan"); firstName.setMaxAge(1);
QUESTION 50
Match the following container and component relationships:
a) WebContainer
1) EJB
b)Application Server
c) Browser
d) Client machine

2) JSP
3) Client component
4 ) Applet

A) a-1,b-2,c-4,d-3
B) a-2,b-1,c-4,d-3
C) a-2,b-1,c-3,d-4
D) a-4,b-3,c-2,d-1
---------------------------------------------------------------------QUESTION 51
---------------------------------------------------------------------Statement A: There is only one config object avaibalbe per web application.
Statement B : The container creates one servlet context object per servlet.
A) A is True and B is False
B) A is False and B is True
C) Both are True
D) Both are False
---------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------QUESTION 52
---------------------------------------------------------------------Which of the following statement is true regarding RequestDispatcher.forward() and
response.sendRedirect()?

A) forward() is handled internally by the container whereas sednRedirect() is handled by browser.


B) forward() cant be used to invoke a servlet in another context, we can only use sendRedirect()
in this case.
C) We should use forward() when accessing resources in the same application because its faster
than sendRedirect() method that required an extra network call. D) All of the above

---------------------------------------------------------------------QUESTION 53
----------------------------------------------------------------------

---------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------------------------

Which of the following entry in web.xml specifies that all the 404 errors from the application will be
handled by a servlet named MyExceptionHandler.

A) <error-handler>
<error-code>404</error-code>
<servlet>/MyExceptionHandler</servlet>
< /error-handler >
B) <error-page>
<error-code>404</error-code>
<location>/MyExceptionHandler</location>
< /error-page >
C) <exception>
<error-code>404</error-code>
<handler>/MyExceptionHandler</handler>
< /exception >
D) <error-code>
<error-num>404</error-num>
<error-page>/MyExceptionHandler</error-page>
< /error-code >
---------------------------------------------------------------------QUESTION 54
---------------------------------------------------------------------What is true regarding the following code in web.xml?
< security-constraint >
<web-resource-collection>
<web-resource-name>A Protected Page</web-resource-name>
<url-pattern>/protected-page.jsp</url-pattern>
</web-resource-collection>

---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------<auth-constraint>
<role-name>tomcat</role-name>
<role-name>manager</role-name>
</auth-constraint>

</security-constraint>
A) It allows the users in manager role to be able to access the protected-page.jsp
B) It does not allows the users in manager role to be able to access the protected-page.jsp C) It
allows users with username ="tomcat" and password="manager" to access the
protectedpage.jsp
D) It restricts access to protected-page.jsp to all users. -------------------------------------------------------------------QUESTION 55
---------------------------------------------------------------------What does the following entry in web.xml do?
< servlet >
<servlet-name>foo</servlet-name>
<servlet-class>com.foo.servlets.Foo</servlet-class>
<load-on-startup>5</load-on-startup>
< /servlet >
A) It is upto the container to decide when to load the servlet . This entry in web.xml has no effect.
B) It loads the servlet when the first request is made to the servlet.
C) It loads the servlet at application startup.
D) It loads the servlet on the 5th request made to the servlet
---------------------------------------------------------------------QUESTION 56
---------------------------------------------------------------------Which of the following http authentication is appropriate for sending sensitive information like
banking transaction etc?
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------A) Basic Authentication


B) Form Based Authentication
C) Digest Authentication
D) All of the above
----------------------------------------------------------------------

QUESTION 57
---------------------------------------------------------------------What is
the output of the following jsp code?:
< %@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" % >
< body >
< c:set var="salary" scope="session" value="${10*5}"/ >
< c:out value="${salary}"/ >
A) Error due to Wrong taglib import statement
B) Error due to wrong use of <c:set> tag
C) Error because arithmatic calculation not allowed in jsp EL.
D) Compiles but no output.
E) 50
---------------------------------------------------------------------QUESTION 58
---------------------------------------------------------------------Identify the custom tag classes which can be extended to create a tag handler class.
1) Tag
2) SimpleTag
3) BodyTag
4) TagSupport
5) BodyTagSupport

---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------A) 1,2,3
B) 3,4,5
C) 4,5
D) 1,2,3,4,5
---------------------------------------------------------------------QUESTION 59
---------------------------------------------------------------------What will happen If you define the following method within a jsp page?
void _jspService(HttpServletRequest request,

HttpServletResponse response)
{
}
A) We can't override this method in jsp.
B) It is OK to override this method sometimes. But not necessory.
C) We must override this method in all jsp pages.
D) This method compiles,runs and produces no output.
---------------------------------------------------------------------QUESTION 60
---------------------------------------------------------------------Which scope will the bean object be stored in the following code?
< jsp:useBean id="obj" class="com.mage.Calculator"/ >
A) page
B) request
C) session
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------D) application
---------------------------------------------------------------------QUESTION 1
--------------------------------------------------------------------public class Test { public static void main (String[]
args) { new Test().go();
}
public void go() {
Runnable r = new Runnable() { public void run() { System.out.print("foo"); }
};
Thread t = new Thread(r);
t.start();
t.start(); } }
What is the result?
A) An exception is thrown at runtime.
B) Compilation fails.
C) The code executes normally and prints "foo".
D) The code executes normally, but nothing is printed.
---------------------------------------------------------------------QUESTION 2
---------------------------------------------------------------------Which Man class properly represents the relationship "Man has a best friend who is a Dog"?
A) class Man extends Dog { }
B) class Man implements Dog { }
C) class Man { private BestFriend dog; }
D) class Man { private Dog bestFriend; }
E) class Man { private Dog<bestFriend>; }
---------------------------------------------------------------------QUESTION 3
---------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------class
Animal
{
String name = "animal";
String makeNoise() { return "generic noise"; }
}
class Dog extends Animal
{
String name = "dog";
String makeNoise() { return "bark"; }
}
public class Test
{ public static void main(String[]
args)
{
Animal an = new Dog();
System.out.println(an.name+" "+an.makeNoise());
}
}
A) animal generic noise
B) animal bark
C) dog bark
D) dog generic noise
---------------------------------------------------------------------QUESTION 4
---------------------------------------------------------------------class Base extends Exception {}
class Derived extends Base {}

public class Main { public static void


main(String args[]) {

---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------// some other stuff


try {
// Some monitored code
throw new Derived();
}
catch(Base b)

System.out.println("Caught base class exception");


}
catch(Derived d) {
System.out.println("Caught derived class exception");
}
}
}
A) Caught base class exception
B) Caught derived class exception
C) Compiler Error because derived is not throwable
D) Compiler Error because base class exception is caught before derived class
---------------------------------------------------------------------QUESTION 5
--------------------------------------------------------------------public class Test { public static void main(String
args[]) {
try {
int a = args.length;

int b = 10 / a;
System.out.print(a);
try {
(a == 1)
= a / a - a;
(a == 2) {
int c[] = {1};
c[8] = 9;

if
a
if

}
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------}
catch (ArrayIndexOutOfBoundsException e) {
System.out.println("TypeA");
}
}
catch (ArithmeticException e) {
System.out.println("TypeB");
}
}
}
A) TypeA
B) 0TypeA
C) 0TypeB
D) TypeB
---------------------------------------------------------------------QUESTION 6
---------------------------------------------------------------------Which Exceptions should be replaced by ? for the code to
compile? class Test{ public static void main(String args[]) throws {
try{
Class.forName("oracle.jdbc.OracleDriver");
Connection con = DriverManager.getConnection(
"jdbc:oracle:oci8:@/localhost:1521/XE", "hr", "hr");
}
catch(? e){ }
catch(? e){ }
}
}
A) ClassNotFoundException,SQLException
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------B) ClassCastException,SQL Exception


C) Exception,SQLException
D) ClassCastException,ClassNotFoundException
---------------------------------------------------------------------QUESTION 7
---------------------------------------------------------------------What will be the result of compiling and running
the following code: import java.io.File; public class
Test {
public static void main(String... args) throws Exception {
File myDir = new File("test");
// myDir.mkdir();
File myFile = new File(
myFile.createNewFile();

myDir, "test.txt");

}}
A) create directory "test" and a file name as "test.txt
B) java.io.IOException
C) Compile with error
D) None of the above
---------------------------------------------------------------------QUESTION 8
---------------------------------------------------------------------Consider the code
int[] x =
{5,6,7,8,9}; int[] y
= x; y[2] = 10;
What is the value of x[2]?
A) 6
B) 7
C) 8
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------D) 10
E) 0
---------------------------------------------------------------------QUESTION 9
---------------------------------------------------------------------public class Test implements Runnable { public void run() {
System.out.print("running");
}
public static void main(String[] args) {
Thread t = new Thread(new Test());
t.run();
t.run();
t.start();
}
}
A) Compilation fails.
B) An exception is thrown at runtime.
C) The code executes and prints "running".
D) The code executes and prints "runningrunning".
E) The code executes and prints "runningrunningrunning".
---------------------------------------------------------------------QUESTION 10
---------------------------------------------------------------------What is the output of the below
code: public class Test { public
static void main(String[] args){
System.out.println(Thread.currentThread().getName());
}
}
A) mainthread
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------B) Thread
C) main
D) currentThread
---------------------------------------------------------------------QUESTION 11 ---------------------------------------------------------------------class MyThread implements Runnable {
public void run(){
System.out.println("Running MyThread");
}
} // end of MyThread class
YourThread extends Thread {
public YourThread(Runnable r) {
super(r);
}
public void run(){
System.out.println("Running YourThread");
}
} // end of YourThread
public class Test { public static void
main(String args[]) { MyThread t1 =
new MyThread(); YourThread t2 =
new YourThread(t1);
t2.start();
}
}
What will be the ouput of the above Code?
A) Running MyThread
B) Running YourThread
C) Running MyThread
Running YourThread
D) Compilation fails
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------E) Runtime error


---------------------------------------------------------------------QUESTION 12
---------------------------------------------------------------------What is the output of the below
code: public class Test { public
static void main(String[] args) {
System.out.println(Thread.currentThread().getPriority());
}
}
A) 10
B) 1
C) 5
D) 7
---------------------------------------------------------------------QUESTION 13
---------------------------------------------------------------------What is the output of the below code?
import java.io.*; import
java.io.Serializable; class A{} public class
Test implements Serializable { private
static A a = new A(); public static void
main(String... args){ Test b = new
Test();
try{
FileOutputStream fs = new
FileOutputStream("b.ser");
ObjectOutputStream os =
new
ObjectOutputStream(fs);
os.writeObject(b);
os.close();
}catch(Exception e){
e.printStackTrace();
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------}
} }
A) Compilation Fail
B) java.io.NotSerializableException: Because class A is not Serializable
C) No Exception at Runtime
D) None of the above
---------------------------------------------------------------------QUESTION 14
---------------------------------------------------------------------Which of the following isolation allows dirty reads and nonrepeatable reads ?
A) Read committed
B) Read uncommitted
C) Repeatable read
D) Serializable
---------------------------------------------------------------------QUESTION 15
---------------------------------------------------------------------Choose incorrect statement about PreparedStatement?
A) SQL Queries are precompiled before execution, when using prepared statement
B) PreparedStatement can take parameters represented by a ?
C) PreparedStatement cannot be used to update or insert in to table
D) PreparedStatement typically provide better performance than Statement when query is
executed multiple times

---------------------------------------------------------------------QUESTION 16
---------------------------------------------------------------------Steps for creating a Custom tag(Re-arrange)
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------A. Package Tag Handlers and TLD file into tag library
B. Write TLD file
C. Write Tag Handlers
D. Reference the TLD in the web-app deployment descriptor
A) A,B,D,C
B) D,C,B,A
C) B,C,A,D
D) A,C,D,B,
---------------------------------------------------------------------QUESTION 17
---------------------------------------------------------------------Which type of ResultSet can be navigated in both directions and will reflect the changes made to
the underlying data in the Database?

A) TYPE_FORWARD_ONLY
B) TYPE_SCROLL_INSENSITIVE
C) TYPE_SCROLL_SENSITIVE
D) ALL MENTIONED ABOVE
---------------------------------------------------------------------QUESTION 18
---------------------------------------------------------------------Design Pattern in which we separate abstraction and its implementation?
A) Decorator Pattern
B) Adapter Pattern
C) Bridge Pattern
D) Creational Pattern
---------------------------------------------------------------------QUESTION 19
------------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------What is the sequence of method execution in Filter?


A)init,doFilter,destroy
B)doFilter,init,destroy
C)destroy,doFilter,init
D)destroy,doFilter
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 20
---------------------------------------------------------------------Which of the following statement is true about servlet filter ?
A)A filter is a reusable piece of code that can transform the content of HTTP requests, responses
and header information.
B)Filters do not generally create a response or respond to a request as servlets do.
C)Filters can act on dynamic or static content.
D)All of the above
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 21
---------------------------------------------------------------------After translation of a JSP source page into its implementation class, The jsp implementation class
is ________ ?

A) final
B) static
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------C) abstract
D) private
---------------------------------------------------------------------QUESTION 22
---------------------------------------------------------------------If in test.jsp \${3+21} : ${3+2-1} What
is the output?

A) ${3+2-1} : 4
B) \${3+2-1} : 4
C) \${4} : 4
D) ${4} : 4
---------------------------------------------------------------------QUESTION 23
---------------------------------------------------------------------All ____________ are notified of context initialization before any filter or servlet in the web
application is initialized.

A) ServletContextListeners
B) HttpSessionListener
C) ServletRequestListener
D) All of the above
---------------------------------------------------------------------QUESTION 24
---------------------------------------------------------------------Which of the below statement is true about session-timeout tag in web.xml?
A)The specified timeout must be expressed in a whole number of MINUTES
B)If the timeout is 0 or less , sessions is NEVER to be timed out
C)If this element is not specified, the container must set its default timeout period
D)All of the above
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 25
---------------------------------------------------------------------The ......................... method executes an SQL statement that may return multiple results.
A) executeUpdate()
B) executeQuery()
C) execute()
D) noexecute()
---------------------------------------------------------------------QUESTION 26
---------------------------------------------------------------------public
Object m()
{
Object o = new Float(3.14F)
Object [] oa = new Object[l]/* Line 5
*/ oa[0] = o /* Line 6 */ o = null /*
Line 7*/ oa[0] = null /* Line 8 */
return o /* Line 9 */ }
When is the Float object, created in line 3, eligible for garbage collection?
A) just after line 5
B) just after line 6
C) just after line 7
D) just after line 8
E) just after line 9

---------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------QUESTION 27
---------------------------------------------------------------------A bean with a property color is loaded using the following statement
< jsp:usebean id="fruit" class="Fruit"/ >
Which of the following statements may be used to set the of color property of the bean. Select the
one correct answer.
A)<jsp:setColor id="fruit" property="color" value="white"/>
B)<jsp:setColor name="fruit" property="color" value="white"/>
C)<jsp:setValue name="fruit" property="color" value="white"/>
D)<jsp:setProperty name="fruit" property="color" value="white">
E)<jsp:setProperty name="fruit" property="color" value="white"/>
F)<jsp:setProperty id="fruit" property="color" value="white">
A) A
B) B
C) C
D) D
E) E
F) F
---------------------------------------------------------------------QUESTION 28
---------------------------------------------------------------------Given:
public interface A{public void m1();} class B
implements A{} class C implements A {public void
m1(){}} class D implements A{public void m1(int x){}}
abstract class E implements A{} abstract class F
implements A{public void m1(){}} abstract class G
implements A{public void m1(int x){}}
What is the result
A) compilation succeeds
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------B) Exactly one class does NOT compile


C) Exactly two classes do NOT compile
D) Exactly four classes do NOT compile
E) Exactly three classes do NOT compile
---------------------------------------------------------------------QUESTION 29
---------------------------------------------------------------------What is the output of below code?
public class Bean{
private String str
Bean(String str ){
this.str = str } public
String getStr() {
return str
}
public boolean equals(Object
o){ if (!(o instanceof Bean)) {
return false
} return ((Bean)
o).getStr().equals(str)
}
public int hashCode() {
return 12345
} public String
toString() { return str
}
}
import java.util.HashSet public class
Test { public static void main(String
... sss) {
HashSet myMap = new HashSet()
String s1 = new String("das")
String s2 = new String("das")
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------Bean s3 = new
Bean("abcdef") Bean s4 =
new Bean("abcdef")
myMap.add(s1)
myMap.add(s2)
myMap.add(s3)
myMap.add(s4)
System.out.println(myMap)
}
}
A) das abcdef
B) das abcdef das abcdef
C) das das abcdef abcdef
D) das
---------------------------------------------------------------------QUESTION 30
---------------------------------------------------------------------What is the output of the below code:
import java.util.*;
class
genericstack <E> {
Stack <E>
stk = new Stack <E>(); public void
push(E obj) {
stk.push(obj);
}
public E pop() {
E obj = stk.pop();
return obj;
}
}
public class Test {
public static void main(String args[]) {
genericstack <String> gs1 = new genericstack<String>();
gs1.push("Hello");

---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------System.out.print(gs1.pop() + " ");


genericstack
<Integer> gs2 = new genericstack<Integer>();
gs2.push(36);
System.out.println(gs2.pop());
}
}
A) Hello
B) 36
C) compile time error
D) run time error
E) Hello 36
---------------------------------------------------------------------QUESTION 31
---------------------------------------------------------------------What will be the output of the below
code: if( "Welcome".trim() ==
"Welcome".trim() )
System.out.println("Equal"); else
System.out.println("Not Equal");
A) compile and display Equal
B) compile and display Not Equal
C) cause a compiler error
D) compile and display NULL
---------------------------------------------------------------------QUESTION 32
---------------------------------------------------------------------What is the output of the below code:
import java.util.*;
public class Test {
private String s;
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------public Test(String s) {
this.s = s; } public
static void
main(String[] args) {
HashSet hs = new
HashSet();
Test ws1 = new Test("aardvark");
Test ws2 = new Test("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());
} }
A) 1
B) 2
C) 3
D) 4 E) 5

---------------------------------------------------------------------QUESTION 33
---------------------------------------------------------------------Which of the following JSP variables are not available within a JSP expression. Select the one
correct answer.

A) out
B) session
C) request
D) response
E) httpsession
F) page
---------------------------------------------------------------------QUESTION 34
---------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------A bean with a property color is loaded using the following statement
< jsp:usebean id="fruit" class="Fruit"/ >
What happens when the following statement is executed. Select the one correct answer.
< jsp:setProperty name="fruit" property="*"/ >
A)This is incorrect syntax of <jsp:setProperty/> and will generate a compilation error. Either value
or param must be defined.
B)All the properties of the fruit bean are initialized to a value of null.
C)All the properties of the fruit bean are assigned the values of input parameters of the JSP page
that have the same name.
D)All the properties of the fruit bean are initialized to a value of *.
A) A
B) B
C) C
D) D
---------------------------------------------------------------------QUESTION 35
---------------------------------------------------------------------JSP pages have access to implicit objects that are exposed automatically. One such object that is
available is request. The request object is an instance of which class?

A) HttpRequest
B) ServletRequest
C) Request
D) HttpServletRequest
---------------------------------------------------------------------QUESTION 36
---------------------------------------------------------------------The sendRedirect method defined in the HttpServlet class is equivalent to invoking the setStatus
method with the following parameter and a Location header in the URL. Select the one correct
answer.
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------A) SC_OK
B) SC_MOVED_TEMPORARILY
C) SC_NOT_FOUND
D) SC_INTERNAL_SERVER_ERROR
E) ESC_BAD_REQUEST
A) A
B) B
C) C
D) D
E) E
---------------------------------------------------------------------QUESTION 37
---------------------------------------------------------------------To send binary output in a response, the following method of HttpServletResponse may be used
to get the appropriate Writer/Stream object. Select the one correct answer.
A) getStream
B) getOutputStream
C) getBinaryStream
D) getWriter
---------------------------------------------------------------------QUESTION 38
---------------------------------------------------------------------Name the class that has getSession method, that is used to get the HttpSession object.
A) HttpServletRequest
B) HttpServletResponse
C) SessionContext
D) SessionConfig
------------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------QUESTION 39
---------------------------------------------------------------------Given the code fragment:
1. ArrayList<Integer> list = new ArrayList<>(1);
2. list.add(1001);
3. list.add(1002);
4. System.out.println(list.get(list.size())); What is the result?

A) Compilation fails due to an error on line 1.


B) An exception is thrown at run time due to error on line 3
C) Anexception is thrown at run time due to error on line 4
D) 1002
---------------------------------------------------------------------QUESTION 40
---------------------------------------------------------------------Given: public class SampleClass {
public static void main(String[] args)
{
AnotherSampleClass asc = new AnotherSampleClass(); SampleClass sc = new SampleClass();
sc = asc;
System.out.println("sc: " + sc.getClass());
System.out.println("asc: " + asc.getClass());
}}
class AnotherSampleClass extends SampleClass {
}
What is the result?
A) sc: class Object asc: class
AnotherSampleClass B) sc:
class SampleClass asc: class
AnotherSampleClass
C) sc: class
AnotherSampleClass asc: class
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------AnotherSampleClass D) sc:
class AnotherSampleClass asc:
class SampleClass

---------------------------------------------------------------------QUESTION 41
---------------------------------------------------------------------Iterator Pattern is a type of _______________
A) Creational Patterns
B) Behavioral Patterns
C) Structural Patterns
---------------------------------------------------------------------QUESTION 42
--------------------------------------------------------------------import java.io.*; public class Test {
public
static void main(String[] args) {
String s1 = "abc";
String s2 = "def";
String s3 = s1.concat(s2.toUpperCase());
System.out.println(s1+s2+s3);
}
}
What is the output of the above code ?
A) abcDEF
B) abcdefabcdef
C) abcdefDEF
D) abcdefabcDEF
---------------------------------------------------------------------QUESTION 43 ----------------------------------------------------------------------

---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------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
B) java.util.LinkedHashMap
C) java.util.HashMap
D) java.util.TreeMap
---------------------------------------------------------------------QUESTION 44
---------------------------------------------------------------------Given:
class Mammal { }
class Raccoon extends Mammal {
Mammal m = new Mammal();
}
class BabyRaccoon extends Mammal { }
Which four statements are true? (Choose four.)
A. Raccoon is-a Mammal.
B. Raccoon has-a Mammal. C. BabyRaccoon is-a Mammal.
D. BabyRaccoon is-a Raccoon.
E. BabyRaccoon has-a Mammal.
F. BabyRaccoon is-a BabyRaccoon.
A) A,B,D,C
B) A,C,E,F
C) C,D,E,A
D) A,B,C,F
E) A,D,E,F
F) B,D,E,F
------------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------QUESTION 45
---------------------------------------------------------------------public
interface Status {
/* insert code here */ int MY_VALUE = 10;
} Which three are valid on line?
( Choose three. )
A. final
B. static
C. native
D. public
E. private
F. abstract
G. protected
A) A,B,C
B) D,E,F
C) A,B,D
D) A,C,D
E) E,F,G
---------------------------------------------------------------------QUESTION 46
--------------------------------------------------------------------class Animal { public String noise() { return "peep"; }
} class Dog extends Animal { public String noise() {
return "bark"; }
}
class Cat extends Animal { public
String noise() { return "meow"; }
}
class Test{
public static void main(String[] args) {
Animal animal = new Dog();
Cat cat = (Cat)animal;
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------System.out.println(cat.noise());
}
}
What is the output of the above code?
A) peep
B) bark
C) meow
D) Compilation fails.
E) An exception is thrown at runtime
---------------------------------------------------------------------QUESTION 47
---------------------------------------------------------------------What is the output of the below code:
class Test{
public static void main(String[] args) {
System.out.println(9+4+"hello"+9+4);
}
}
A) 94hello94
B) 13hello13
C) 13hello94
D) 94hello13
---------------------------------------------------------------------QUESTION 48
---------------------------------------------------------------------Select
the correct option for wait(long timeout)?
A)Causes the current thread to wait until either another thread invokes the notify() or notifyAll()
methods for this object, or a specified timeout time has elapsed.

---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------B)causes the currently executing thread to sleep for the specified number of milliseconds
C) current thread to wait until another thread invokes the notify() or notifyAll() method for
this object.

A) A
B) B
C) C
---------------------------------------------------------------------QUESTION 49
---------------------------------------------------------------------What is the output of the below code:
class Test implements Runnable{
public static void main(String[] args) {
Test t = new Test(new Runnable);
t.start();
t.run();
}
@Override
public void run() {
System.out.println("Thread Running");
}
}
A) Thread Running
B) Thread Running
ThreadRunning
C) Compilation error
D) run time error
---------------------------------------------------------------------QUESTION 50
----------------------------------------------------------------------

---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------What is the output for the below


code? Public class A{ int i=10; public
void printValue(){
System.out.println("Value-A");
};
}
public class B extends A{ int
i=12; public void
printValue(){
System.out.println("ValueB");
}}
public class Test{ public static void
main(String[]args){
A a= new B();
a.printValue();
System.out.println(a.i);
}}
A) Value-B 11
B) Value-B 10
C) Value-A 10
D) Value-A 11
---------------------------------------------------------------------QUESTION 51
---------------------------------------------------------------------public class X implements Z{ public
String toString(){return "I am X";}
public static void main(String[] args){
Y myY = new Y();
X myX = myY;
Z myZ = myX;
System.out.println(myZ);
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------}
class Y extends X{ public String
toString(){return "I am Y";}} interface
Z{}
What is the reference type of myZ and what is the type of the object it references?
A) Reference type is Z;object type is Z
B) Refernce type is Y, objecct type is Y
C) Reference type is Z;object type is Y
D) Refernce type is X;object type is Z
---------------------------------------------------------------------QUESTION 52
---------------------------------------------------------------------Which of the following interfaces has getWriter() method?
A) HttpServletRequest
B) HttpServletResponse
C) ServletRequest
D) ServletResponse
---------------------------------------------------------------------QUESTION 53
---------------------------------------------------------------------Identify the testing technique that is used to test the features/functionality of the system or
Software, and covers all the scenarios including failure paths and boundary cases.

A) Performance testing
B) Functional testing
C) Integration testing
D) State testing
---------------------------------------------------------------------QUESTION 54
---------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Which of the following pattern works as a bridge between two incompatible interfaces.?
A) Builder Pattern
B) Adapter Pattern
C) Prototype pattern
D) Filter Pattern
---------------------------------------------------------------------QUESTION 55
---------------------------------------------------------------------Which of the following design pattern identifies common communication patterns between
objects ?

A) Creational patterns
B) Behavioral patterns
C) Structural Patterns
---------------------------------------------------------------------QUESTION 56
---------------------------------------------------------------------What is an actor model?
A) An actor model can represent an external entity which communicates with the system
B) An actor can represent a specific physical entity
C) An Actor model can represent a role played by the User.
D) All of the above
---------------------------------------------------------------------QUESTION 57
--------------------------------------------------------------------final class Complex {
private double re, im;
public Complex(double re, double im) {
this.re =
re;
this.im = im;
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------}
Complex(Complex c)
{
System.out.println("Copy constructor
called");
re = c.re;
im = c.im;
}
public String toString() {
return "(" + re + " + " + im + "i)";
}
}
class Main {
public static void main(String[] args) {
Complex c1 = new Complex(10, 15);
Complex c2 = new Complex(c1);
Complex c3 = c1;
System.out.println(c2);
}
}
A) Copy constructor called
(10.0 + 15.0i)
B) Copy constructor called
(0.0 + 0.0i )
C) (10.0 + 15.0i)
D) (0.0 + 0.0i)
---------------------------------------------------------------------QUESTION 58
---------------------------------------------------------------------JSP's in a web application use ErrorInfo.jsp as the error page. Which directive in ErrorInfo.jsp
below would enable it to display the Exception class name and the Exception message?

A) <%@page isErrorPage="true" %>


B) <%@page errorPage="true" %>
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------C) <%@include errorPage="true" %>


D) <%@page errorPage="ErrorInfo.jsp" %>
---------------------------------------------------------------------QUESTION 59
---------------------------------------------------------------------class
Base {}

class Derived extends Base { public


static void main(String args[]){
Base a = new Derived();
System.out.println(a instanceof Derived);
}
}
A) true
B) false
---------------------------------------------------------------------QUESTION 60
---------------------------------------------------------------------Which Is the suitable webcomponent to perform tasks like authentication, data compression,
logging and auditing?
A) Filter
B) Servlet
C) JSP
D) servlet container
---------------------------------------------------------------------QUESTION 61
---------------------------------------------------------------------What is the output of the below
code: public class Test { public
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------static void main(String[] args) {


double x = 0, y = 5.4324;
try {
System.out.println( (y/x) );
}
catch (Exception e) {
System.out.println("Exception");
}
catch (Throwable t) {
System.out.println("Error");
}}}
A) Exception
B) Error
C) Infinity
D) Exception Error
---------------------------------------------------------------------QUESTION 62
---------------------------------------------------------------------What is the output of the below
code: public class Test { public
static void main(String[] args) {
big_loop: for (int i = 0; i < 3; i++) {
try { for (int j = 0; j < 3; j++) {
if
(i==j) continue;
else if (i>j)
continue big_loop;
System.out.print("A ");
}
}
finally {
System.out.print("B ");
}
System.out.print("C ");
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------}}}
A) A B C A B C A B C
B) A A B C A A A B C A A A B C
C) A A B B C A C A
D) A A B C B B
---------------------------------------------------------------------QUESTION 63
--------------------------------------------------------------------Choose the incorrect option for Singleton pattern A)
Provide a default Private constructor.
B) Define a static Private object instance.
C) The client should be independent of how the products are created
D) Make the access method synchronized to prevent Thread
problems.
E) Override the object clone method to prevent cloning.
A) A
B) B
C) C
D) D
E) E
---------------------------------------------------------------------QUESTION 64
---------------------------------------------------------------------Which statement is static and synchronized in JDBC API?
A) executeQuery()
B) executeUpdate()
C) getConnection()
D) prepareCall()

---------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------QUESTION 65
---------------------------------------------------------------------This method is used to execute any SQL statement with a "SELECT" clause, that returns the
result of the query as a result set.
A. executeUpdate();
B. executeQuery();
C. execute();
A) A
B) B
C) C
---------------------------------------------------------------------QUESTION 66
---------------------------------------------------------------------Which of the following is a Connected Rowset?
A) JdbcRowSet
B) JoinRowSet
C) CachedRowSet
D) WebRowSet
---------------------------------------------------------------------QUESTION 67
---------------------------------------------------------------------All Rowset objects are Scrollable and updatable by default?
A) true
B) false
---------------------------------------------------------------------QUESTION 68
------------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------Which of the following method is used to create a object for calling a stored procedure?
A) prepareStatement
B) prepareCall
C) storedProcedure
D) statement
---------------------------------------------------------------------QUESTION 69
---------------------------------------------------------------------What is the output of the below code,
public class Test {
public static void main(String[] args) {
System.out.println("String "+new Integer("4")+5);
} }
A) String 9
B) String 45
C) compilation error
D) run time error
---------------------------------------------------------------------QUESTION 70
---------------------------------------------------------------------What is the value of s3 in the below code,
String s1 = "India";
String s2 =s1;
String s3 = s1.equals(s2);
A) true
B) false
C) compilation error
D) run time error

---------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------QUESTION 71
---------------------------------------------------------------------In a Sequence diagram, Slanted lines describe _____________
A) order of messages
B) race conditions
C) Propogation delay of messages
D) none of the above
---------------------------------------------------------------------QUESTION 72
---------------------------------------------------------------------Choose
the invalid declaration of String array?

A) String[] s
B) String s[]
C) Stirng [s]
D) String []s ---------------------------------------------------------------------QUESTION 73
---------------------------------------------------------------------What will be output for the following program?
public class Boxing2 { public static
void main(String[] args) {
byte b =
10;
method(b);
}
static void method(int i){
System.out.println("Primitive Type call");
}
static void method(Integer i){
System.out.println("Wrapper Type Call");
}
}
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------1) Wrapper Type Call


2) Primitive Type Call
3) Compiler Error
4) Compiles fine, throws runtime exception
A) 1
B) 2
C) 3
D) 4
---------------------------------------------------------------------QUESTION 74
---------------------------------------------------------------------What is the output of below code,
File f = new File("c:\\test\\abc.txt");
System.out.println(f.getName());
A) abc
B) abc.txt
C) c:\test\abc.txt
D) compile error
---------------------------------------------------------------------QUESTION 75
---------------------------------------------------------------------public class ArrayTest { int[] one; int[] two;
@Before
public void first(){one= new int[]{1,2}; two= new int[]{1,2};}
@Test
public void test() { assertArrayEquals(one, two);}
}
What is the result of executing the above JUnit Test?

---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------A) Test fails as references of both the arrays are not equal
B) Test passes
C) Compilation fails as there is no method assertArrayEquals in Junit
D) Runtime exception occurs
---------------------------------------------------------------------QUESTION 76
--------------------------------------------------------------------public class Fixture { @AfterClass
public static void after1(){ System.out.print("T"); }
@BeforeClass
public static void before1(){ System.out.print("C"); }
@Test
public void t1() { System.out.print("A"); }
@Test
public void t2() { System.out.print("U"); }
}
What is the output of the above JUnit Test?
A) CATCUT
B) CAUT
C) TAUC
D) TACTUC
---------------------------------------------------------------------QUESTION 77
---------------------------------------------------------------------public
class ArrTest {
int[] a = {1,2}; int[] b = {1,2}; int[] c = {1};
@Test public void t1() { assertArrayEquals(a, b);}
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------@Test public void t2() { assertArrayNotEquals(a, c);}


}
What is the result of executing the above JUnit Test?
A) Test t1 passes, t2 fails
B) Test t1, t2 passes
C) Test t1,t2 fails
D) Compilation fails
---------------------------------------------------------------------QUESTION 78
--------------------------------------------------------------------public class Seq { @Test public void b() {}
@Test public void a() {}
@Test public void c() {}
}
In Which sequence, the below Test methods will execute?
A) a -> b -> c
B) c -> a -> b
C) b -> a -> c
D) Sequence is Unpredictable
---------------------------------------------------------------------QUESTION 79
---------------------------------------------------------------------public
class ExTest {

@Test(expected=ParseException.class
) public void t1() { int i =
Integer.parseInt("1.25");
}
}
What is the result of executing the above JUnit Test?
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------A) Test Passes as ParseException is thrown


B) Test fails as ParseException is not thrown
C) Compilation fails as method t1 does not use 'throws' for declaring Exception --------------------------------------------------------------------QUESTION 80
--------------------------------------------------------------------public class TimeTest { @Test(timeout=1) public
void t1() {
ArrayList list = new ArrayList();
assertTrue(list.isEmpty()); //line 1
}
}
Which of the below is correct for the above test case?
A) Test fails, if test execution takes more than 1 millisecond
B) Test passes, irrespective of the time taken for execution
C) Test passes, if test execution takes less than 1 second
D) Compilation error in line 1
---------------------------------------------------------------------QUESTION 81
---------------------------------------------------------------------In the Publish-Subscribe messaging model, the subscribers register themselves in a topic and are
notified when new messages arrive to the topic. Which pattern does most describe this model?

A) Adapter
B) Notifier
C) Observer
D) State
---------------------------------------------------------------------QUESTION 82
------------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------You are trying to add a class already written in another application to serve clients, beside other
classes, in your system. All other classes have the same interface, the incoming class has a
totally different interface than the clients expect, but contains all required functionalities.
What kind of refactoring is needed to make this class fit in with minimum changes in your
system?
A) apply the Proxy Pattern
B) apply the Adapter Pattern
C) create a new class which implements the expected interface and copy and paste the code
from the class in the other application to this new class
D) apply the Bridge Pattern
---------------------------------------------------------------------QUESTION 83
---------------------------------------------------------------------When would you use the Singleton design pattern?
A. to limit the class instantiation to one object
B. to provide global access to one instance across the system
C. to ensure that a certain group of related objects are used together
D. to abstract steps of construction of complex objects
A) A
B) A,B
C) A,B,C
D) A,B,D
---------------------------------------------------------------------QUESTION 84
---------------------------------------------------------------------public
class Test1 {
public static void main(String[] args) throws InterruptedException
{ T t = new T(); t.start(); synchronized (t) {
System.out.println("wait"); t.wait();
System.out.println(t.count);
}
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------}
}
class T extends Thread{
int count = 0; public
void run(){
System.out.println("T");
synchronized (this) {
for (int i = 0; i < 2; i++) {
count +=i;
}
notify();
}
}
}
A) 1
wait
T
B) wait
T
1
C) wait
1
T
D) T 1
wait
---------------------------------------------------------------------QUESTION 85
--------------------------------------------------------------------class Wings{} class Legs{} abstract class
Animal{Legs leg;} abstract class Bird extends
Animal{Wings wing;} class Parrot extends Bird{}
class Eagle extends Animal{} Choose Incorrect
correct options
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------1. Bird is a Animal


2. Bird Has Wings
3. Bird Has Legs
4. Parrot is a Animal
5. Eagle is a Bird
6. Eagle has Legs
7. Eagle has Wings
8. Parrot has Wings and Legs
A) 8
B) 5 & 7
C) 6 & 7
D) 4
---------------------------------------------------------------------QUESTION 86
---------------------------------------------------------------------Which of the Following Stream classes can be used to read primitive datatypes from a file?
A) DataInputStream
B) ObjectInputStream
C) PrimitiveInputStream
D) Both DataInputStream and ObjectInputStream
---------------------------------------------------------------------QUESTION 87
--------------------------------------------------------------------public class Test { public static void main(String[]
args) { Set tr = new TreeSet(); tr.add("Hello");
tr.add(123); System.out.println(tr);
}
}
What is the output of the above code?
A) [123, Hello]
---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------B) [123, Hello]


C) [Hello]
D) ClassCastException will be thrown
---------------------------------------------------------------------QUESTION 88
--------------------------------------------------------------------public class Test { public static void main(String[]
args) { Vector v = new Vector(); v.add("a");
v.add("b");
v.add("c");
Enumeration e = v.elements();
while(e.hasMoreElements()) {
Object o = e.nextElement();
System.out.println(o);
}
}
}
What is the output of the above code?
A) a b c
B) c b a
C) RunTime Error
D) Compile Time Error
---------------------------------------------------------------------QUESTION 89
---------------------------------------------------------------------public
class ByteTest {
public static void main(String[] args)
{
String obj = "abc";
byte b[]
= obj.getBytes();
ByteArrayInputStream obj1 = new ByteArrayInputStream(b);

---------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------System.out.println((char)obj1.read());
}
What is the output?
A) a
B) b
C) c
D) abc
E) 97
---------------------------------------------------------------------QUESTION 90
---------------------------------------------------------------------Which of the following can be used to dynamically include copyright.jsp in other jsps of
an application? 1 . include directive
2. include jsp action
3. import jstl tag
A) 1
B) 2
C) 3
D) 2 & 3
----------------------------------------------------------------------

---------------------------------------------------------------------

You might also like