• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use Bean Questions

 
Ben Harrison
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
141 Given MyBean.java
public class MyBean {
public MyBean (int x) { }
}
and test.jsp
<jsp:useBean id="my" class="test.MyBean" scope="page"/>
Which of the following statements regarding the above code is correct ?
A It will work fine
B Compiler will complain because there is no type attribute specified.
C Will fail at Runtime
D It will fail at compile time



It says answer is D, but I saw another reference that said the answer is C.

I believe the answer is D, I would think the compiler would pick it up.
 
Sandeep Sirsekar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i can see two compile time errors

first of all you MUST have

package declared in .java file
if that's declared then

second,
you must have a public non-arg constructor as constructor is defined with argument compiler won't generate non-arg constructor for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic