Rob Spoor wrote:Java is not released under GPL; see http://java.sun.com/javase/faqs.jsp#2q1.
However, even if it were, only derivatives of the JDK, JRE or Oracle code would have to be released under the GPL. Any code you write using the tools is not a derivative as you could also use a different compiler and JVM to run them. Therefore, you are free to choose any license for the Java code you write yourself (provided it's not the derivative of some other code, you'd need to check its license for that).
Pedro Kowalski wrote:Hello Jessid!
Firstly - did you try to run the example on your own? I guess so, as you spotted the compilation error, and it's true - if these are the exact files the question mentioned about - than a compilation error will occur.
Secondly - this kind of question is hardly possible to be present at the exam, but you should be very suspicious all the time. Also note that on the real exam (SCWCD 6) I personally bumped into (at least) two questions which source code won't even compile (!) and it was obvious that there was a mistake in the question (missing DD element, missing parenthesis etc.) because there was no 'compilation error' option. So be extra careful in such cases!
I would advice you to firstly assume that you are wrong and the question is prepared correctly. If you are 150% sure that the code is wrong because there is no correct answer, choose the one that best suits you (i.e. assume what the question is supposed to ask you about, what the author is trying to test you for, etc.). Just remember that this is really the last resort just to avoid receiving 0 points for not giving any answer.
Ulf Dittmer wrote:The problem would be detected at runtime of the web app, but at compile time of the JSP (since that's where the code containing the no-arg constructor is used).
"Since MyBean does not have a no-arg constructor, the container cannot instantiate it and hence a Compilation error
Bear Bibeault wrote:There are a number of errors with this code:
Firstly, using scriptlets in a JSP is a poor practice that should have been eradicated years ago. Bad idea.
Secondly, the code assues that the variable exception is not null. This is an invalid assumption. Hence, when it is null, a null pointer exception is raised.
Stefan Evans wrote:Indeed. If you check out the setProperty tag you will find out that
"If a parameter has an empty or null value, the corresponding bean property is not set. "
An empty string counts as "empty" for purposes of this tag, and so the setter is not called.