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.
1) It won't compile. 2) It is a valid jsp line and it will print the variable called name. 3) It will compile but it will always produce null as the output. 4) It will work if you create a javabean class with only one variable of type java.lang.String.
Pls reply, which one u all think is the best answer ?
Sorry, I was wrong. Jsp page will compile. For this question no output is there.
But if we will replace java.lang.String with java.lang.Object it will call the toString() method on name object and print the result. We will get the output something like this:java.lang.Object@1d8f162
In both the cases, it will not print null.
As long as the class attribute contains some concreate class , we will get the output.
If the class attribute contains any Abstract class or Interface, we will get InstantiationException at run time.
Joined: May 28, 2005
Well, the answer to above question is 2). It will not print nything. Chittranjan is right here. But, wen Iam running it on my server -its not getting compiled anyways. Can u help me more on this ?
Joined: Feb 09, 2006
You Should run the program exactly with wht written in the question. If you have any <jsp:setProperty> and <jsp:getProperty>, it will not compile.
If you can give the jsp content, I can find out the problem.