Professional Documents
Culture Documents
Javaprogramming Objective (0500536)
Javaprogramming Objective (0500536)
01. Which four options describe the correct default values for array elements of the types indicated?
1 int -> 0
2 String -> "null"
3 Dog -> null
4 char -> '\u0000'
5 float -> 0.0f
6 boolean -> true
(A) 1, 2, 3, 4
(B) 1, 3, 4, 5
(C) 2, 4, 5, 6
(D) 3, 4, 5, 6
02. Which one of these lists contains only Java programming language keywords?
(A) class, if, void, long, Int, continue
(B) goto, instanceof, native, finally, default, throws
(C) try, virtual, throw, final, volatile, transient
(D) strictfp, constant, super, implements, do
08. Which one of the following will declare an array and initialize it with five numbers?
(A) Array a = new Array(5);
(B) int [] a = {23,22,21,20,19};
(C) int a [] = new int[5];
(D) int [5] array;
PCODE : 0500536 (JAVA PROGRAMMING)
09. Which three are valid declarations of a char?
1 char c1 = 064770;
2 char c2 = 'face';
3 char c3 = 0xbeef;
4 char c4 = \u0022;
5 char c5 = '\iface';
6 char c6 = '\uface';
(A) 1, 2, 4
(B) 1, 3, 6
(C) 3, 5
(D) 5 only
15. You want subclasses in any package to have access to members of a superclass. Which is the most
restrictive access that accomplishes this objective?
(A) public
(B) private
(C) protected
(D) transient
24. You want a class to have access to members of another class in the same package. Which is the most
restrictive access that accomplishes this objective?
(A) public
(B) private
(C) protected
(D) default access
PCODE : 0500536 (JAVA PROGRAMMING)
25. What is the widest valid returnType for methodA in line 3?
public class ReturnIt
{
returnType methodA(byte x, double y) /* Line 3 */
{
return (long)x / y * 2;
}
}
(A) int
(B) byte
26. Class A
{
protected int method1(int a, int b)
{
return 0;
}
}
Which is valid in a class that extends class A?
(A) public int method1(int a, int b) {return 0; }
(B) private int method1(int a, int b) { return 0; }
(C) public short method1(int a, int b) { return 0; }
(D) static protected int method1(int a, int b) { return 0; }
28. Which two of the following are legal declarations for nonnested classes and interfaces?
1 final abstract class Test {}
2 public static interface Test {}
3 final public class Test {}
4 protected abstract class Test {}
5 protected interface Test {}
6 abstract public class Test {}
(A) 1 and 4
(B) 2 and 5
(C) 3 and 6
(D) 4 and 6
PCODE : 0500536 (JAVA PROGRAMMING)
29. Which of the following class level (nonlocal) variable declarations will not compile?
(A) protected int a;
(B) transient int b = 3;
(C) private synchronized int e;
(D) volatile int d;
34. switch(x)
{
default:
System.out.println("Hello");
}
Which two are acceptable types for x?
1 byte
2 long
3 char
4 float
5 Short
6 Long
(A) 1 and 3
(B) 2 and 4
(C) 3 and 5
(D) 4 and 6
PCODE : 0500536 (JAVA PROGRAMMING)
35. public class While
{
public void loop()
{
int x= 0;
while ( 1 ) /* Line 6 */
{
System.out.print("x plus one is " + (x + 1)); /* Line 8 */
}
}
}
Which statement is true?
(A) There is a syntax error on line 1.
(B) There are syntax errors on lines 1 and 6.
(A) AC
(B) BC
(C) ACD
(D) ABCD
PCODE : 0500536 (JAVA PROGRAMMING)
47. What will be the output of the program?
public class X
{
public static void main(String [] args)
{
try
{
badMethod(); /* Line 7 */
System.out.print("A");
}
catch (Exception ex) /* Line 10 */
{
System.out.print("B"); /* Line 12 */
}
finally /* Line 14 */
{
System.out.print("C"); /* Line 16 */
}
System.out.print("D"); /* Line 18 */
}
public static void badMethod()
{
throw new RuntimeException();
}
}
(A) AB
(B) BC
(C) ABC
(D) BCD
53. What is the name of the method used to start a thread execution?
(A) init();
(B) start();
(C) run();
(D) resume();
54. Which two of the following methods are defined in class Thread?
start()
wait()
notify()
run()
terminate()
(A) 1 and 4
(B) 2 and 3
(C) 3 and 4
(D) 2 and 4
55. Which three guarantee that a thread will leave the running state?
yield()
wait()
notify()
notifyAll()
sleep(1000)
aLiveThread.join()
Thread.killThread()
(A) 1, 2 and 4
(B) 2, 5 and 6
(C) 3, 4 and 7
(D) 4, 5 and 7
PCODE : 0500536 (JAVA PROGRAMMING)
56. Which of the following will directly stop the execution of a Thread?
(A) wait()
(B) notify()
(C) notifyall()
(D) exits synchronized code
57. Which method must be defined by a class implementing the java.lang.Runnable interface?
(A) void run()
(B) public void run()
(C) public void start()
(D) void run(int priority)
59. 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) After thread A is notified, or after two seconds.
(B) After the lock on B is released, or after two seconds.
(C) Two seconds after thread A is notified.
(D) Two seconds after lock B is released.
60. Which of the following will not directly cause a thread to stop?
(A) notify()
(B) wait()
(C) InputStream access
(D) sleep()
61. Which class or interface defines the wait(), notify(),and notifyAll() methods?
(A) Object
(B) Thread
(C) Runnable
(D) Class
PCODE : 0500536 (JAVA PROGRAMMING)
62. public class MyRunnable implements Runnable
{
public void run()
{
// some code here
}
}
which of these will create and start this thread?
(A) new Runnable(MyRunnable).start();
(B) new Thread(MyRunnable).run();
(C) new Thread(new MyRunnable()).start();
(D) new MyRunnable().start();
66. There are core interfaces are used in just about every Hibernate application. Using these interfaces,
you can store and retrieve persistent objects and control transactions. Select the interfaces that is not
core interface.
(A) Configuration interface
(B) Session interface
(C) Query and Criteria interfaces
(D) User interface
PCODE : 0500536 (JAVA PROGRAMMING)
67. Which of the following is NOT a step in the Hibernate communication with RDBMS?
(A) Create HQL Query
(B) Execute query to get list containing Java objects
(C) Create session from configuration object
(D) Load the Hibernate configuration file and create configuration object
69. Which of the following are most common configuration methods of Hibernate Configuation
(A) Mapping files and XML configuration
(B) http.conf
(C) XML Configuration only
(D) web.config
71. __________ objects can be passed across layers all the way up to the presentation layer without
having to use any DTOs (Data Transfer Objects). You can later re-attach them to another session
Possible correct answers:
(A) Persistent
(B) Detached
72. Which of these class is used to read and write bytes in a file?
(A) FileReader
(B) FileWriter
(C) FileInputStream
(D) InputStreamReader
PCODE : 0500536 (JAVA PROGRAMMING)
73. Which of these method of InputStream is used to read integer representation of next available byte
input?
(A) read()
(B) scanf()
(C) get()
(D) getInteger()
75. Which of these is a method to clear all the data present in output buffers?
(A) clear()
(B) flush()
(C) fflush()
(D) close()
76. Which of the following is NOT a best practice for defining your Hibernate persistent classes?
(A) You must have a default no-argument constructor for your persistent classes and there
should be getXXX() (i.e accessor/getter) and setXXX( i.e. mutator/setter) methods for
all your persistable instance variables.
(B) You should implement the equals() and hashCode() methods based on your business
key and it is important not to use the id field in your equals() and hashCode()
definition if the id field is a surrogate key (i.e. Hibernate managed identifier). This is
because the Hibernate only generates and sets the field when saving the object.
(C) It is recommended to implement the Serializable interface. This is potentially useful if
you want to migrate around a multi-processor cluster.
(D) The persistent class should be final because if it is final then lazy loading can be used
by creating proxy objects.
77. Which of these classes is used for input and output operation when working with bytes?
(A) InputStream
(B) Reader
(C) Writer
(D) All of the mentioned
PCODE : 0500536 (JAVA PROGRAMMING)
78. What is the output of this program?
import java.io.*;
public class filesinputoutput {
public static void main(String[] args) {
String obj = "abc";
byte b[] = obj.getBytes();
ByteArrayInputStream obj1 = new ByteArrayInputStream(b);
for (int i = 0; i < 2; ++ i) {
int c;
while ((c = obj1.read()) != -1) {
if(i == 0) {
System.out.print((char)c);
}
}
}
}
}
import java.io.*;
class filesinputoutput {
public static void main(String args[]) {
InputStream obj = new FileInputStream("inputoutput.java");
System.out.print(obj.available());
}
}
Note: inputoutput.java is stored in the disk.
(A) true
(B) false
(C) prints number of bytes in file
(D) prints number of characters in the file
PCODE : 0500536 (JAVA PROGRAMMING)
81. What is the output of this program?
import java.io.*;
public class filesinputoutput {
public static void main(String[] args) {
String obj = "abc";
byte b[] = obj.getBytes();
ByteArrayInputStream obj1 = new ByteArrayInputStream(b);
for (int i = 0; i < 2; ++ i) {
int c;
while ((c = obj1.read()) != -1) {
if (i == 0) {
System.out.print(Character.toUpperCase((char)c));
obj2.write(1);
}
}
System.out.print(obj2);
}
}
}
import java.io.*;
public class filesinputoutput {
public static void main(String[] args) {
String obj = "abc";
byte b[] = obj.getBytes();
ByteArrayInputStream obj1 = new ByteArrayInputStream(b);
for (int i = 0; i < 2; ++ i) {
int c;
while ((c = obj1.read()) != -1) {
if (i == 0) {
System.out.print(Character.toUpperCase((char)c));
}
}
}
}
}
(A) abc
(B) ABC
(C) ab
(D) AB
PCODE : 0500536 (JAVA PROGRAMMING)
83. Java supports input/output of data through the classes included in the _______ package:
(A) Java.oi
(B) Java.out
(C) Java.in
(D) Java.io
85. The ________ method help in clearing the contents of the buffer:
(A) Flush()
(B) Clear()
(C) Rub()
(D) Vanish()
90. Which refers to a channel through which data flow from the source to the destination:
(A) String
(B) Character
(C) Stream
(D) Buffer
92. The _______class distinguish among numbers, identifiers, quoted strings and different common styles.
(A) Stringtokenizer
(B) Streamtokenizer
(C) Inputstream
(D) Buffer
93. The ______ class is used to display the result on an output device:
(A) Read Stream
(B) Write Stream
(C) Display Stream
(D) Print Stream
94. The _______ class is used to read characters from the file:
(A) Stream Reader
(B) Character Reader
(C) Input Reader
(D) File Reader
PCODE : 0500536 (JAVA PROGRAMMING)
95. Data Input Stream class contains methods to read________
(A) Non primitive data type
(B) Primitive data type
96. Input data type what is the characters and sequence of characters marking the begging or end of a unit
of data.
(A) Parsing
(B) Boolean
(C) Token
(D) Delimiters
98. The_____ class is used to read input from the console input device:
(A) Input Stream Reader
(B) Output Stream Reader
(C) Byte Stream Reader
(D) Buffer Stream Reader
99. When we invoke repaint() for a java.awt. Component object, the AWT invokes the method:
(A) update()
(B) draw()
(C) show()
(D) paint()
100. Which of the following is a correct signature for the paint() method?
(A) static void paint(Graphics[] g)
(B) public paint(Graphics g)
(C) public void paint(Graphics g)
(D) public static void paint(Graphics g)
PCODE : 0500536 (JAVA PROGRAMMING)
101. To import all the classes in the package java.awt, you write
(A) import java.awt;
(B) import java.*;
(C) import java.awt.*;
(D) You don't need to import the package; it is implicitly imported by the Java runtime
102. Which of the following is a correct signature for the main() method?
(A) static void main(String[] args[])
(B) public static void main(String[] args)
(C) public void main(String[] args)
(D) public static void main(strings[] args)
103. Which specifies that all the character within the range between low & high are white space
characters:
(A) Void wordChars
(B) Void whitespaceChars
(C) Void resetSyntax()
(D) Void Chars
105. Java provides _______ to convert byte-oriented data into character-oriented data:
(A) InputStreamReader
(B) OutputStreamReader
(C) StringStreamReader
(D) PrintStreamReader
108. Which of the following methods can be used to draw the outline of a square within a java.awt.
Component object?
(1) fillRect()
(2) drawLine()
(3) drawRect()
(4) drawString()
(5) drawPolygon()
(A) (2), (3) & (5)
(B) (1), (2), (3) & (5)
(C) (1), (2) & (3)
(D) (3), (4) & (5)
109. Which of the following methods can be used to remove a java.awt.Component object from the
display?
(A) delete()
(B) remove()
(C) disappear()
(D) hide()
110. The setBackground() method is part of the following class in java.awt package:
(A) Graphics
(B) Component
(C) Applet
(D) Container
115. I want to add the MessageSource functionality to application, providing access to messages in i18
n-style in my application. Which one should I use ?
(A) ApplicationContext
(B) Properties File
(C) Servlet Context
PCODE : 0500536 (JAVA PROGRAMMING)
116. Can you instantiate a static inner class in Spring ?
(A) No. Static classes are not supported
(B) Yes. They are instantiated by default with the class
(C) Yes. But you will have to use the binary name of the class
117. Spring requires all your class to have default constructors. Failure to do so will result an exception at
startup.
(A) False
(B) True
121. To run a compiled Java program, the machine must have what loaded and running?
(A) Java virtual machine
(B) Java compiler
(C) Java bytecode
(D) A Web browser
PCODE : 0500536 (JAVA PROGRAMMING)
122. Which JDBC driver Type(s) can be used in either applet or servlet code?
(A) Both Type 1 and Type 2
(B) Both Type 1 and Type 3
(C) Both Type 3 and Type 4
(D) Type 4 only
123. ________ is an open source DBMS product that runs on UNIX, Linux and Windows.
(A) MySQL
(B) JSP/SQL
(C) JDBC/SQL
(D) Sun ACCESS
124. What is sent to the user via HTTP, invoked using the HTTP protocol on the user's computer, and run
on the user's computer as an application?
(A) A Java application
(B) A Java applet
(C) A Java servlet
127. Which JDBC driver Type(s) can you use in three-tier architecture and if the Web server and the
DBMS are running on the same machine?
(A) Type 1 only
(B) Type 2 only
(C) Both Type 3 and Type 4
(D) All of Type 1, Type 2, Type 3 and Type 4
PCODE : 0500536 (JAVA PROGRAMMING)
128. What programming language(s) or scripting language(s) does Java Server Pages (JSP) support?
(A) VBScript only
(B) Jscript only
(C) Java only
(D) All of the above are supported
129. What servlet processor was developed by Apache Foundation and Sun?
(A) Apache Tomcat
(B) Apache Web server
(C) Sun servlet processor
(D) None of the above is correct.
131. What is invoked via HTTP on the Web server computer when it responds to requests from a user's
Web browser?
(A) A Java application
(B) A Java applet
(C) A Java servlet
(D) None of the above is correct.
132. Your application supports multiple client types including HTTP clients. Your business layer is
implemented using Enterprise Java Beans. Which of the following is best suited for maintaining
client state?
(A) Stateful session beans
(B) Entity Beans
(C) HttpSession attributes
133. Which enterprise bean type is defined without any client view interfaces?
(A) BMP Entity bean
(B) CMP Entity bean
(C) Stateful Session bean
(D) Message Driven Bean
PCODE : 0500536 (JAVA PROGRAMMING)
134. Which technology provides the flexibility to swap between XML processors with no application code
changes?
(A) JAXP
(B) SAX
(C) XSLT
(D) JAAS
135. You want to locate an existing bean object but do not want to create a new instance, if an existing in-
stance is not available. Which of the following bean attributes will you use in the jsp:useBean
action?
(A) class
(B) type
(C) beanName
(D) class and type
136. Which of the following should NOT be used to share data between servlets in a distributed web
application?
(A) Attributes of ServletContext
` (B) Enterprise Java Beans
(C) Attributes of HttpSession
(D) Database
138. If the HTTP error 500 is generated by your servlet, you do not want to show the "Internal Server
Error" page to the client. Instead, you want a custom error page to be displayed. What is the best way
to accomplish this?
(A) Forward the user to the error page using HttpServletResponse.sendRedirect method.
(B) Forward the user to the error page using RequestDispatcher.forward method.
(C) Specify the mapping of the error-code 500 and the error page in the deployment
descriptor.
(D) It is not possible to accomplish this.
PCODE : 0500536 (JAVA PROGRAMMING)
139. A web application is located in a directory named 'school'. Its deployment descriptor will be located in
which of the following?
(A) school
(B) school/WEB-INF
(C) school/META-INF
(D) WEB-INF/school
140. An EJB is required to perform credit card verification. All necessary information such as card number
and amount will be supplied as parameters to a single business method invocation that processes the
verification. Assuming that performance is critical, which bean type BEST suits the requirement?
(A) Stateful Session Bean
(B) Stateless Session Bean
(C) Message Driven Bean
(D) Entity Bean
141. Which of these packaging options of enterprise beans are recommended for most J2EE applications?
(A) Package each enterprise bean for an application in its own EJB module
(B) Package all enterprise beans for an application in one EJB module
(C) Package all related enterprise beans for an application in one EJB module
(D) None of These
142. __________are great when your application requires a lot of real programming to accomplish its task.
(A) HTML
(B) Apache
(C) Servlets
(D) None of the Above
144. The most important point about MVC is the idea of separating the business logic and data access
layers from the presentation layer.
(A) True
(B) False
PCODE : 0500536 (JAVA PROGRAMMING)
145. To Extract the data from the beans which property is used.
(A) jsp:getProperty
(B) jsp:writeProperty
(C) jsp:setProperty
(D) All of the Above
148. You are using session-based data sharing, Which method is preferable to use to transfer control from
the servlet to the JSP page
(A) response.write
(B) request.sendRedirect
(C) response.sendRedirect
(D) out.print
149. If are the website developer and want to display counter on home page regarding Number of Live user
which scope will you use for Beans ?
(A) Page
(B) Request
(C) Session
(D) Application
150. If you would like to store user type (like admin or user) in the beans object which kind of sharing is
used?
(A) Page
(B) Request
(C) Session
(D) Application
PCODE : 0500536 (JAVA PROGRAMMING)
151. Persistent values should be accessed through methods called _____________________
(A) getvalue and setvalue
(B) getXX and setXX.
(C) Both of the Above
(D) None of the Above
152. Which of the following is legal JSP syntax to print the value of i.
(A) <%int i = 1;%>
<%= i; %>
(B) <%int i = 1;
i; %>
(c) <%int i = 1%>
<%= i %>
(D) <%int i = 1;%>
<%= i %>
153. A JSP page called test.jsp is passed a parameter name in the URL using http://localhost/test.jsp?
name="John". The test.jsp contains the following code.
<%! String myName=request.getParameter();%>
<% String test= "welcome" + myName; %>
<%= test%>
(A) The program prints "Welcome John"
(B) The program gives a syntax error because of the statement
<%! String myName=request.getParameter();%>
(C) The program gives a syntax error because of the statement
<% String test= "welcome" + myName; %>
(D) The program gives a syntax error because of the statement
<%= test%>
154. Which of the following correctly represents the following JSP statement. Select the one correct
answer.
<%=x%>
(A) <jsp:expression=x/>
(B) <jsp:expression>x</jsp:expression>
(C) <jsp:statement>x</jsp:statement>
(D) <jsp:declaration>x</jsp:declaration>
PCODE : 0500536 (JAVA PROGRAMMING)
155. What gets printed when the following JSP code is invoked in a browser. Select the one correct an-
swer.
<%= 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.
156. Which of the following correctly represents the following JSP statement. Select the one correct
answer.
<%x=1;%>
(A) <jsp:expression x=1;/>
(B) <jsp:expression>x=1;</jsp:expression>
(C) <jsp:statement>x=1;</jsp:statement>
(D) <jsp:scriptlet>x=1;</jsp:scriptlet>
157. Which of the following are correct. Select the one correct answer.
(A) JSP scriptlets and declarations result in code that is inserted inside the _jspService
method.
(B) The JSP statement <%! int x; %> is equivalent to the statement
<jsp:scriptlet>intx;</jsp:scriptlet%>.
(C) The following are some of the predefined variables that maybe used in JSP expression
- httpSession, context.
(D) To use the character %> inside a scriptlet, you may use %\> instead.
158. What gets printed when the following is compiled. Select the one correct answer.
<% int y = 0; %>
<% int z = 0; %>
160. 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 print the value of color property of the bean. Select
the one correct answer.
(A) <jsp:getColor bean="fruit"/>
(B) <jsp:getProperty id="fruit" property="color"/>
(C) <jsp:getProperty bean="fruit" property="color"/>
(D) <jsp:getProperty name="fruit" property="color"/>
161. 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:setProperty name="fruit" property="color" value="white"/>
(C) <jsp:setValue name="fruit" property="color" value="white"/>
(D) <jsp:setProperty name="fruit" property="color" value="white">
162. 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 *.
163. Is the following statement true or false. If the isThreadSafe attribute of the page directive is false, then
the generated servlet implements the SingleThreadModel interface.
(A) True
(B) False
PCODE : 0500536 (JAVA PROGRAMMING)
164. Which of the following represents a correct syntax for usebean.
(A) <jsp:usebean id="fruit scope ="page"/>
(B) <jsp:usebean id="fruit type ="String"/>
(C) <jsp:usebean id="fruit type ="String" beanName="?"/>
(D) <jsp:usebean id="fruit class="Fruit" beanName="Fruit"/>
166. Which of the following statements are true for <jsp:usebean>. Select the two correct answers.
(A) The id attribute must be defined for <jsp:usebean>.
(B) The scope attribute must be defined for <jsp:usebean>.
(C) The class attribute must be defined for <jsp:usebean>.
(D) The <jsp:usebean> must include either type or class attribute or both.
167. Which of these are legal attributes of page directive. Select the two correct answers.
(A) include
(B) scope
(C) errorPage
(D) debug
168. 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.
PCODE : 0500536 (JAVA PROGRAMMING)
169. Assume that you need to write a JSP page that adds numbers from one to ten, and then print the
output.
<% int sum = 0;
for(j = 0; j < 10; j++) { %>
// XXX --- Add j to sum
<% } %>
// YYY --- Display ths sum
Which statement when placed at the location XXX can be used to compute the sum. Select the one
correct statement
(A) <% sum = sum + j %>
(B) <% sum = sum + j; %>
(C) <%= sum = sum + j %>
(D) <%= sum = sum + j; %>
170. Now consider the same JSP example as last question. What must be added at the location YYY to
print the sum of ten numbers.
(A) <% sum %>
(B) <% sum; %>
(C) <%= sum %>
(D) <%= sum; %>
171. 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
172. JSP pages have access to implicit objects that are exposed automatically. Name the implicit object that
is of type HttpSession.
(A) session
(B) application
(C) httpSession
(D) httpsession
PCODE : 0500536 (JAVA PROGRAMMING)
173. A Java bean with a property color is loaded using the following statement
<jsp:usebean id="fruit" class="Fruit"/>
What is the effect of the following statement.
<jsp:setproperty name="fruit" property="color"/>
Select the one correct answer.
(A) An error gets generated because the value attribute of setAttribute is not defined.
(B) The color attribute is assigned a value null.
(C) The color attribute is assigned a value "".
(D) If there is a non-null request parameter with name color, then its value gets assigned
to color property of Java Bean fruit.
174. The page directive is used to convey information about the page to JSP container. Which of these are
legal syntax of page directive. Select the two correct statement
(A) <% page info="test page" %>
(B) <%@ page info="test page" session="false"%>
(C) <%@ page isThreadSafe=true %>
(D) <%@ page isErrorPage="errorPage.jsp" %>
175. Is the following JSP code legal? Select the one correct statement.
<%@page info="test page" session="false"%>
<%@page session="false"%>
(A) Yes. This is legal JSP syntax.
(B) No. This code will generate syntax errors.
176. A JSP page needs to generate an XML file. Which attribute of page directive may be used to specify
that the JSP page is generating an XML file.
(A) contentType
(B) generateXML
(C) type
(D) outputXML
177. A JSP page uses the java.util.ArrayList class many times. Instead of referring the class by its
complete package name each time, we want to just use ArrayList. Which attribute of page directive
must be specified to achieve this. Select the one correct answer.
(A) extends
(B) import
(C) include
(D) package
PCODE : 0500536 (JAVA PROGRAMMING)
178. Which of these are true.
(A) The default value of isThreadSafe attribute of page directive is true.
(B) If isThreadSafe attribute of page directive is set to true, then JSP container dispatches
request for the page sequentially.
(C) When isThreadSafe attribute of page directive is set to false, a thread is created for
each request for the page.
(D) Setting isThreadSage attribute to true for JSP pages, can lead to poor performance.
179. Which of the following are examples of JSP directive. Select the two correct answers.
(A) include
(B) exclude
(C) import
(D) taglibrary
180. Which of these is true about include directive. Select the one correct answer.
(A) The included file must have jspf extension.
(B) The XML syntax of include directive in <jsp:include file="fileName"/> .
(C) The content of file included using include directive, cannot refer to variables local to
the original page.
(D) When using the include directive, the JSP container treats the file to be included as if
it was part of the original file.
181. Name the implicit variable available to JSP pages that may be used to access all the other implicit
objects.
(A) page
(B) pageContext
(C) context
(D) object