File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Mock exam questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Mock exam questions" Watch "Mock exam questions" New topic
Author

Mock exam questions

Ranjani Theyagarajan
Greenhorn

Joined: Feb 08, 2006
Posts: 19
Am going to take up my exam within couple of days.
It would be gr8 if you guys help me for the answer of the following questions.

1)
test.jsp
===============

<% String str="hello"; %>
<%= str %>
<jsp:include page="another.jsp" flush="true" />
<% str+=" World";
out.println(str);
%>


another.jsp
===========
<% String str="hi";
out.println(str); %>


What is the output for the test.jsp file?

==========================================================================


2) Select the EL fragment which will produce compilation erro? select two choices


a) ${1+'1'}
b) ${varDoesntExist+1}
c) ${sessionScope * 2}
d) ${2/varDoesntExist}
e) ${2/ varContainingZero }
f) ${varDoesntExist1 <varDoesntExist2}
g) ${!true - !false}

======================================================================

3) Acme Inc decides to develop a Swing application to acces the central office data from branches all
over the world. The central office would enter business data using this application and the
branches would mostly read these data over the networl. te application would use EJB for
accessing the enterprise data. one of the primary goal of the application is to provide faster
response time both at central and branch office.

The other goal is to reduce the application dev time by devloping the business and UI Compenents
in parallel without waiting for each other.

Given this scneario which of the following j2EE design would solve the problem effectively?
select two choices.


a) Intercepting Filter
b) MVC
c) Front controller
d) Servive Locator
e) Business delegate
f) Value object

==========================================================================

4) PostTest.html
===============

<html>
<body>
<form method="POST" action="/servlet/PostTest">
val1=<input type="text" name="value1"><br>
val2=<input type="text" name="value2"><br>
<input type="submit" name="AddButton">
</form>
</body>
</html>



PostTest.java
==============


public void doPost(HttpServletRequest req,HttpServletResponse res){
BufferedReader inReader=req.getReader();
PrintWriter out=res.getWriter();

String val1Str=inReader.readLine();
String val2Str=inReader.readLine();

out.println("Value obtained manually =" val1Str);
out.println("Value obtained manually =" val2Str);

out.println("Value obtained again is =" req.getParameter("Value1"));
out.println("Value obtained again is =" req.getParameter("Value2"));

}

The values entered are value1=500 and value2=600. what is the o/p?

a) compilation error

b) value obationed manually = null
value obationed manually = null
value obationed again is = 500
value obationed again is = 600

c) value obationed manually =

value1=500 &&value2=600&&AddButton=Submit+Query
value obatained again manually is = null
value obationed again is = 500
value obationed again is = 600


d) value obationed manually =

value1=500 &&value2=600&&AddButton=Submit+Query
value obatained again manually is = null
value obationed again is = null
value obationed again is = null


==========================================================================

5) what is the o/p?

<% sesson.setAttribute("varCents","20");
%>
$100.${varCents}

1) compliation error
2) classcastException
3) prints $100.20
4) prints $100.$20

===============================================================


6) can a userdefined identifier be named sessionScope in a jsp file?


Thanks in Advance.

Warm Regards,
Ranjani
Yati Tan
Ranch Hand

Joined: May 28, 2005
Posts: 56
r they frm hfsj ?
[ February 16, 2006: Message edited by: Yati Tandon ]

SCJP 1.4<br />SCJA 1.0<br />SCWCD 1.4
Ranjani Theyagarajan
Greenhorn

Joined: Feb 08, 2006
Posts: 19
Nope... these question are from a mock exam...
Sandhya Lever
Ranch Hand

Joined: Aug 15, 2005
Posts: 90
1.hello hello world
2.c,g
3.e
4.b I think
5.3
6.yes


SCJP | SCWCD |SCBCD |SCDJWS |SCEA
shanthisri mocherla
Ranch Hand

Joined: Sep 05, 2005
Posts: 119
the answer for question 1 is
hello hi helloWorld.
"hi " from another.jsp will be included there in the ouput .




6.when I used sessionScope as a variable in setAttribute method and then used it in EL expression I got this output
org.apache.commons.el.ImplicitObjects$3@162d950


<% session.setAttribute("sessionScope",20); %>
$100.${sessionScope}

Shanthi
[ February 16, 2006: Message edited by: shanthisri mocherla ]
vu ngoc thanh
Greenhorn

Joined: Jun 11, 2005
Posts: 2
4. The answer is D
This is because when you use inReader.readLine(), data of request will be read only once. So when you use req.getParameter("Value1") after using readLine(), the value is null


ngoc thanh
P Chittaranjan
Ranch Hand

Joined: Feb 09, 2006
Posts: 47
The answere for Q4 should be compilation error.

public void doPost(HttpServletRequest req,HttpServletResponse res){
this is missing the throws clause(throws ServletException,IOException).


Thanks,<br />Chittaranjan<br />SCJP 5.0,SCWCD1.4,SCBCD 5
Ranjani Theyagarajan
Greenhorn

Joined: Feb 08, 2006
Posts: 19
Let's assume that doPost method declares IOException and ServletException.. then what would be the result.
P Chittaranjan
Ranch Hand

Joined: Feb 09, 2006
Posts: 47
If your program don't have any compile time error the output will be

d) value obationed manually =

value1=500 &&value2=600&&AddButton=Submit+Query
value obatained again manually is = null
value obationed again is = null
value obationed again is = null
vu ngoc thanh
Greenhorn

Joined: Jun 11, 2005
Posts: 2
When you overide a method, you needn't declare throws clause in methods of parent class or interface it implements. So the method
public void doPost(HttpServletRequest req,HttpServletResponse res) still run
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

I am trying to answer your queries.


1)
test.jsp
===============

<% String str="hello"; %>
<%= str %>
<jsp:include page="another.jsp" flush="true" />
<% str+=" World";
out.println(str);
%>


another.jsp
===========
<% String str="hi";
out.println(str); %>
What is the output for the test.jsp file?


The answer should be "hi hello World" If the writer is buffered, Otherwise it will "hello hi hello World", as if the out is not buffered it will not flushed


==========================================================================


2) Select the EL fragment which will produce compilation erro? select two choices


a) ${1+'1'}
b) ${varDoesntExist+1}
c) ${sessionScope * 2}
d) ${2/varDoesntExist}
e) ${2/ varContainingZero }
f) ${varDoesntExist1 <varDoesntExist2}
g) ${!true - !false}

======================================================================
My Answers are C and G
The outpu of other options are
a) 2 b) 1 d) Infinity e) Infinity f) false

3) Acme Inc decides to develop a Swing application to acces the central office data from branches all
over the world. The central office would enter business data using this application and the
branches would mostly read these data over the networl. te application would use EJB for
accessing the enterprise data. one of the primary goal of the application is to provide faster
response time both at central and branch office.

The other goal is to reduce the application dev time by devloping the business and UI Compenents
in parallel without waiting for each other.

Given this scneario which of the following j2EE design would solve the problem effectively?
select two choices.


a) Intercepting Filter
b) MVC
c) Front controller
d) Servive Locator
e) Business delegate
f) Value object

I go for B and E

==========================================================================

4) PostTest.html
===============

<html>
<body>
<form method="POST" action="/servlet/PostTest">
val1=<input type="text" name="value1"><br>
val2=<input type="text" name="value2"><br>
<input type="submit" name="AddButton">
</form>
</body>
</html>



PostTest.java
==============


public void doPost(HttpServletRequest req,HttpServletResponse res){
BufferedReader inReader=req.getReader();
PrintWriter out=res.getWriter();

String val1Str=inReader.readLine();
String val2Str=inReader.readLine();

out.println("Value obtained manually =" val1Str);
out.println("Value obtained manually =" val2Str);

out.println("Value obtained again is =" req.getParameter("Value1"));
out.println("Value obtained again is =" req.getParameter("Value2"));

}

The values entered are value1=500 and value2=600. what is the o/p?

a) compilation error

b) value obationed manually = null
value obationed manually = null
value obationed again is = 500
value obationed again is = 600

c) value obationed manually =

value1=500 &&value2=600&&AddButton=Submit+Query
value obatained again manually is = null
value obationed again is = 500
value obationed again is = 600


d) value obationed manually =

value1=500 &&value2=600&&AddButton=Submit+Query
value obatained again manually is = null
value obationed again is = null
value obationed again is = null

My answer is A. The doPost must throws the IOException and Servlet Exception or hanldle internally.
If the methods signature is properly defined The answer will be D

==========================================================================

5) what is the o/p?

<% sesson.setAttribute("varCents","20");
%>
$100.${varCents}

1) compliation error
2) classcastException
3) prints $100.20
4) prints $100.$20

===============================================================
Here is typo in session speling , otherwise the output is 3


6) can a userdefined identifier be named sessionScope in a jsp file?


Yes, as long as it is not used in EL


Hope it help
Thanks


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Vishal Chugh
Ranch Hand

Joined: Oct 27, 2007
Posts: 177
once again , very nice link . I have also checked ansers myself


Thank you Narendra Dhande!!

I have doubt about below :
3) Acme Inc decides to develop a Swing application to acces the central office data from branches all
over the world. The central office would enter business data using this application and the
branches would mostly read these data over the networl. te application would use EJB for
accessing the enterprise data. one of the primary goal of the application is to provide faster
response time both at central and branch office.

The other goal is to reduce the application dev time by devloping the business and UI Compenents
in parallel without waiting for each other.

Given this scneario which of the following j2EE design would solve the problem effectively?
select two choices.


a) Intercepting Filter
b) MVC
c) Front controller
d) Servive Locator
e) Business delegate
f) Value object
quote:

I go for B and E

Howcome for E??? B is fine.


and about below :
${sessionScope * 2}
${!true - !false} i got compiler error , is it beacuse i used keywords(sessionScope and true/false) in wrong contexts?? (true/false not treated as 0 or 1 as unknowns , nulls , infinity are treated )
Abdul Rahman
Ranch Hand

Joined: Jul 04, 2008
Posts: 63
hi, the answer is as below for the above questions:

1 - hello hi hello World
2- c and g will give compilation error.
3- My bet will be b and f. since the data will be read over the n/w, and the response time should be faster the value object should be the ideal choice.
4 - answer: b
5 - answer: 3
6 - yes you can but its generally a bad idea and should be avoided in real time scenario.

All the best Ranjani.


Abdul
SCJP5, SCWCD5, [scwcd wall of fame]
manojreddy yaram
Greenhorn

Joined: Apr 04, 2009
Posts: 2



1) hello hello hi world
2) e, g
3) a, d
4) c
5) 4
6) yes

















thank's
Ranjani Theyagarajan
Abdul Rahman
Ranch Hand

Joined: Jul 04, 2008
Posts: 63
hi manoj,

can you explain your answers ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mock exam questions