This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Mock exam question doubt? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply locked New topic

Mock exam question doubt?

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9967


The question above is from David Bridgewater and the answer is given as E. I thought C?? won't the System.out.println write to the server console (log)???

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9967

oops...sorry moderators, actually when I tried posting it, it gave me some errors so I used my browser back button and resubmitted it again and later I found it to be duplicated. You can delete this post as I'll use the other one!
Sergio Tridente
Ranch Hand

Joined: Mar 22, 2007
Posts: 329

I think E is the correct answer.

Note that the example is using two kind of scriptlets: declarations (<%! %> and scripting expressions (<% %>. The Date code is inside an scripting expression, so it will be put inside the _jspService method during translation. The other two blocks are declarations, which means they will be put outside the _jspService method. What is more, both blocks are declaring a jspInit method, which will be run only once during servlet initilization (that's why the second time you'll see no output in the log).

I hope I made myself clear.

SCJP 1.4 (88%) - SCJP 5.0 Upgrade (93%) - SCWCD 1.4 (97%) - SCBCD 5.0 (98%)
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

Closing as duplicate of this thread. Please continue discussions there.

A good workman is known by his tools.
I agree. Here's the link:
subject: Mock exam question doubt?
It's not a secret anymore!