• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Answers to Mock Questions

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys! Here are the answers to the mock questions that I had posted...
Link to Mock Questions :
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=26&t=000882
Note: I may have keyed in some of the answers incorrectly. Please try to confirm the answers before you accept them and kindly post your suggestions/comments on the answers in this discussion thread and I'll make the necessary modifications, if needed, ASAP.
1. d
2. b
3. c
4. a,c,d,f
5. a,c
6. b,d
7. a,d
8. d
9. b,c,d
10. c
11. b
12. a,b,c
13. a,b,c,d
14. d
15. a
16. b,c,d
17. a
18. b,c
19. a
20. b
21. b
22. a
23. b,c
24.
25. b
26. a
27. b
28. b
29. a,b,c
30. a
31. b
32. a
33. b
34. b
35. c
36. a
37. a
38. b
39. a
40. c
[ March 16, 2002: Message edited by: Sridhar Raman001 ]
[ March 16, 2002: Message edited by: Sridhar Raman001 ]
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are some problems with the answers. Please comment
17. In CMP Entity Beans, which of the following statements is true?
a. The Primary Key Class should not define any constructors
b. The primary key class must define a no-argument constructor

You have supplied answer (a)
As per EJB by Richard Monson-Haefel Pg 158 “The no-argument constructor is required for container-managed persistence”. So the answer (b) is correct option.
22. In EJB, What type of exception is thrown when a system error occurs ?
a. EJBException
b. RemoteException
c. Exception
d. BeanException
You have supplied answer (a)
As per EJB by Richard Monson-Haefel Pg 312 “System exception are RuntimeExceptions, RemoteExceptions, and their subtypes. The EJBException is a subclass of the RuntimeException, so it is considered a system exception"
So option (b) is also right. Since Exception class is the base class for all types of exceptions it may also be included in the right options. Please comment.
24. Is ejbPassivate() invoked by the container when ejbRemove() is invoked?
a. True
b. false
No Answer is supplied. It should be (b) because in ejb specification there is no mention of calling ejbPassivation() when ejbRemove() is called. If you see output in Mastering EJB by Ed Roman pg 128 there is no call of ejbPassivation() before ejbRemove().
27. In EJBs, Which two callback methods can be used for synchronizing the bean's state with the database
a. ejbStore() and ejbLoad()
b. ejbActivate() and ejbPassivate()
c. ejbStore() and ejbPasivate()
d. ejbLoad() and ejbActivate()
Answer supplied is (b).
It is essentially we are talking about Entity Bean Where ejbActivate() is used to reinitialize the non persistant fields in bean instance i.e. to remove dirty values not synchronizing with the database. As per EJB by Richard Monson-Haefel Pg 200 and ejb specifications the correct answer should be (a).

:roll: [/LIST] himanshu_airon@yahoo.com
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

As per EJB by Richard Monson-Haefel Pg 158 �The no-argument constructor is required for container-managed persistence�. So the answer (b) is correct option


Yes but not in the Primary Key class. I think it is in the EJBObject class?

So option (b) is also right. Since Exception class is the base class for all types of exceptions it may also be included in the right options. Please comment.


No because EJBException is not a RemoteException, it is not in the same Heirarchy. RemoteException is not a Superclass of EJBException.

As per EJB by Richard Monson-Haefel Pg 200 and ejb specifications the correct answer should be (a).


Actually Load and Store automatically access the database. The question asks what can be used to synchronize the bean's state. which can be done in the ejbActivate and ejbPassivate methods. You don't need to put anything in the store or load because it is handled for you there.
My 2 cents.
Mark
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer to question 17:
17. In CMP Entity Beans, which of the following statements is true?
a. The Primary Key Class should not define any constructors
b. The primary key class must define a no-argument constructor

should be (b). Please refer to Sun's J2EE tutorial, Chapter 5 BMP. The following is copied from the tutorial:
For bean-managed persistence, a primary key class must meet these requirements:
The access control modifier of the class is public.
All fields are declared as public.
The class has a public default constructor.
The class implements the hashCode() and equals(Object other) methods.
The class is serializable.

Howie
 
Howie Woo
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I missed the CMP part in the question, I guess I need to do more studying :roll:
Howie
 
Howie Woo
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, let me try again. In the same tutorial, Chapter 6, CMP, there are the following statements:
For container-managed persistence, a primary key class must meet the following requirements:
The access control modifier of the class is public.
All fields are declared as public.
The fields are a subset of the bean's persistent fields.
The class has a public default constructor.
The class implements the hashCode() and equals(Object other) methods.
The class is serializable.
Looks like the only difference between the primary key for CMP and that for BMP is that the CMP one's fields must be a subset of the bean's persistent fields.
Howie
 
Sridhar Raman
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Here are my comments...
(17) I think you got the question wrong. It says the 'Entity Bean' class should not define constructors. Not the primary key class... constructors can't be defined in a (any) bean class. A no-argument constructor is required for CMP to invoke the Class.newinstance on the PK class.
(22) EJBException is right as it is a type of RuntimeException.... RemoteException....Yes, RemoteException can also be thrown if there is a system error.
(27) Yes, the answer is ejbStore() and ejbLoad(). ejbPassivate() and ejbActivate() are used for releasing or acquiring access to resources such as network connections,etc, My negligence....
(24) I am really not sure about the answer.
Suppose the client invokes ejbRemove() operation, will the container invoke the ejbPassivate() to free up any resources??? I am inclined to think that it would but I dont know the answer. Anybody got a say on this???

Thanks Himanshu, for poining these out and also the references you have provided in this context....
-Sridhar-
 
himanshu airon
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Howie
for additional reference in case of question 17 on CMP I miscquoted the question.
17. In CMP Entity Beans, which of the following statements is true?
a. The Entity Bean Class should not define any constructors
b. The Entity Bean class must define a no-argument constructor
obviously ejb does not allow constructors for bean class.
I should have thanked Sridhar earlier for all his labour for compiling all Q's & A's. I would take this opportunity to thank him again for his comments.
Sridhar, logically when ejbRemove() operation is invoked to release the resources container shall call ejbPassivate() but if we see server-side output even after putting a SOP in ejbPassivate() and ejbRemove(). When we call ejbRemove() there is no call to ejbPassivate() on the screen. So I conclude that on calling ejbRemove()
1. In case of Session Beans, bean instance is dereferenced and sources are released as the context object is released as per container internal commands. Bean Instance wait for garbage collection, or go to Method ready pool, as per container policy.
2. In case of Entity Beans, First record from database is deleted, unsetEntityContext() is called, with this container takes the responsibility for releasing of acquired resources, it is internally done by the container. The dereferenced bean Instance is garbage collected or move to instance pool as per container policy.
Check pg 232 & 254 of Mastering EJB by Ed Roman for Server Side output.
Himanshu Airon
himanshu_airon@yahoo.com
 
himanshu airon
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Howie
for additional reference in case of question 17 on CMP I miscquoted the question.
17. In CMP Entity Beans, which of the following statements is true?
a. The Entity Bean Class should not define any constructors
b. The Entity Bean class must define a no-argument constructor
obviously ejb does not allow constructors for bean class.
I should have thanked Sridhar earlier for all his labour for compiling all Q's & A's. I would take this opportunity to thank him again for his comments.
Sridhar, logically when ejbRemove() operation is invoked to release the resources container shall call ejbPassivate() but if we see server-side output even after putting a SOP in ejbPassivate() and ejbRemove(). When we call ejbRemove() there is no call to ejbPassivate() on the screen. So I conclude that on calling ejbRemove()
1. In case of Session Beans, bean instance is dereferenced and sources are released as the context object is released as per container internal commands. Bean Instance wait for garbage collection, or go to Method ready pool, as per container policy.
2. In case of Entity Beans, First record from database is deleted, unsetEntityContext() is called, with this container takes the responsibility for releasing of acquired resources, it is internally done by the container. The dereferenced bean Instance is garbage collected or move to instance pool as per container policy.
Check pg 232 & 254 of Mastering EJB by Ed Roman for Server Side output.
Himanshu Airon
himanshu_airon@yahoo.com
 
Sridhar Raman
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Corrections to the answers...
Thanks, Aman, for your comments. I typed in the answers half-asleep in the middle of the night and I guess I keyed in some of them incorrectly. Please find my comments below.
1. The answer is correct. It is D. SSL is not a type of firewall. Packet filter and stateful packet filters work on a much lower level than a proxy. The proxy can be used to validate application data.
2. The question was framed incorrectly. The question should read as 'optional' instead of 'not optional'. Anyway, the validation of client side certificate at the server is the only optional step. The other 3 are needed to establish the SSL handshake.
3. C. The answer is right. a and b are obviously wrong. 3 DOES NOT say that SSL can't be configured to a port below 1024. Ports upto 1024 are reserved ports for a specific list of protocols. The applications need to have root privileges to use these ports. Of course, this is only a widely used convention. It is not a rule. Anyway, the answer does not say that SSL can't be configured below ports 1024.
5. The answers are a and c. Yeah, that was pretty glaring, indeed. SSL is not a high level protocol like SMTP or HTTP. It sits betweem the application layer protocols like HTTP, SMTP, etc and the low level TCP-IP layer. That's a big reason why SSL has been widely acceptable and is very flexible unlike S-HTTP or secure HTTP which is only an extension of HTTP.
My apologies for the incorrect answers. Will review the answers sometime. Thanks for your understanding.
-sridhar-
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sridhar Raman001:
Hey guys! Here are the answers to the mock questions that I had posted...
Link to Mock Questions :
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=26&t=000882
Note: I may have keyed in some of the answers incorrectly. Please try to confirm the answers before you accept them and kindly post your suggestions/comments on the answers in this discussion thread and I'll make the necessary modifications, if needed, ASAP.
1. d
2. b
3. c
4. a,c,d,f
5. a,c
6. b,d
7. a,d
8. d
9. b,c,d
10. c
11. b
12. a,b,c
13. a,b,c,d
14. d
15. a
16. b,c,d
17. a
18. b,c
19. a
20. b
21. b
22. a
23. b,c
24.
25. b
26. a
27. b
28. b
29. a,b,c
30. a
31. b
32. a
33. b
34. b
35. c
36. a
37. a
38. b
39. a
40. c
[ March 16, 2002: Message edited by: Sridhar Raman001 ]
[ March 16, 2002: Message edited by: Sridhar Raman001 ]

 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answer for 29. a,b,c seems to be wrong.
How come a EJBHome find method caused a transition. I thought it doesn't according to Ed Roman. Find methods is executed at Pooled state?
 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question 7
7. Which of the following is true about HTTP?
a. HTTP is stateless
b. HTTP maintains state information between requests
c. HTTP is connectionless
d. HTTP is connection oriented
Ans: should be a and c right ?. Your list shows a,d
 
Raees Uzhunnan
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is answer for the question 30 is correct ?
30. When is unsetEntityContext() invoked on an Entity bean?
a. When the entity bean is to be garbage collected
b. After an entity bean is garbage collected
c. after the finalize() method has been invoked on the EntityBean
d. None of the above
Somebody comment pls...
 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


c. HTTP is connectionless
d. HTTP is connection oriented
Ans: should be a and c right ?. Your list shows a,d



Nope, they're right. Definitely connection oriented. See the discussion in this thread
 
Raees Uzhunnan
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See HTTP is considered Connection less because it does not maintain a connection to a server between client requests. It creates a new connection and destroys it end of every call. The connection oriented App protocols maintains a connection or pool of connection to the server. These are called connection oriented service. Of course you cannot have a communication without a transport layer connection .
Any comments ?
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
-------------------------------------
18. The home interface associated with an Entity Bean
a. must declare at least one create() method
b. May not declare any create() methods
c. must declare the findByPrimaryKey() method
d. May not declare any finder methods
-------------------------------------
The provided correct answer is b, c.
-------------------------------------
However, I don't find anywhere ( Monson-Haefel or others ) the restriction mentioned at b. The only thing concerning the home interface for Entity beans that I did found is that the create() method is optional, we can choose not to implement one when we want to restrict creating accesss to clients, allowing them to handle the beans just by using the find() methods.
So it looks to me that the only correct answer is c, neither a nor b beeing enforced by any rule.
Am I missing something ?
Billy
 
Raees Uzhunnan
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are correct !. There are enterprise beans that only reads data or collection of data and does not do any update or insert. Mostly those comes from legacy applications where inserts and updates may be made by other applications. Only findByPromaryKey is necessary

Raees
 
If you open the box, you will find Heisenberg strangling Shrodenger's cat. And waving this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic