This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes some mock questions.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "some mock questions.." Watch "some mock questions.." New topic

some mock questions..

mallika shah
Ranch Hand

Joined: May 11, 2006
Posts: 164
Hello Friends,

Can you please help me guiding correct answers to these questions.
And also see if what i thought was correct or incorrect.

The deployment descriptor for the Foo session bean looks similar to this:

10. <enterprise-beans>
11. <session>
12. ...
13. <ejb-name>Foo</ejb-name>
14. <ejb-class>ms.FooBean</ejb-class>
15. ...
16. <resource-ref>
17. <res-ref-name>jdbc/BarDB</res-ref-name>
18. <res-type>javax.sql.DataSource</res-type>
19. <res-auth>Container</res-auth>
20. <res-sharing-scope>Shareable</res-sharing-scope>
21. </resource-ref>
22. ...
23. </session>

Assume that a deployer binds this to an actual resource. The implementation of Foo contains a reference to a Context object bound to the variable initCtx and a reference to a SessionContext object bound to the variable ctx. Which statement successfully retrieves the datasource?

@Resource DataSource ds;
(DataSource) ctx.lookup("java:comp:env/jdbc/BarDB");
@Resource(name=?jdbc/BarDB?, type=javax.sql.DataSource)

my ans:3

A developer is given a JMS message-driven bean, which has no descriptors or metadata that describe acknowledge modes or subscription durability. In addition, the message-driven bean uses bean-managed transactions and is subscribed to a topic.

What two message-driven bean behaviors can the developer expect to see? (Choose two.)

If a message is received, the container automatically acknowledges it.
If a message is received, the container does NOT automatically acknowledge it.
Messages will NOT be missed, even if the EJB server is NOT running.
Messages can be missed if the EJB server is NOT running.
Specifying subscription durability for a topic has no effect.

my ans: 1,4


Given an excerpt of a Book entity (it is just missing the import statements):

10. @Entity
11. public class Book implements Serializable {
12. @Id
13. @GeneratedValue(strategy = GenerationType.AUTO)
14. private Integer id;
15. String bookName;
16. protected int price;
17. enum Status {IN, OUT};
18. @Enumerated( EnumType.ORDINAL )
19. Status status;
20. transient int bar;
21. java.util.Map<Integer, String> comments;
22. protected Book() {};
23. }

No descriptors are used.

Which statement is correct about this entity?

There is an error on line 11. It must NOT implement Serializable.
Adding a single @Transient annotation makes this entity valid.
The visibility declarations on some of the variables causes an exception.
The enumeration or its field definition on lines 17, 18, or 19 is NOT valid.
There is an error in the identity definition on lines 12, 13, or 14.

My ans:"The visibility declarations on some of the variables causes an exception."

Meng Tan
Ranch Hand

Joined: Jan 20, 2001
Posts: 115

My answers are:
Q1: 3
Q2: 1, 4
Q3: 2

Meng Tan
I agree. Here's the link:
subject: some mock questions..
It's not a secret anymore!