Hi Wang,
Are you referring to Martin Fowler's UML Distilled 3rd Edition or 2nd Edition ? If I am showing it as an attribute, do I need to draw a line to link it to the actual object?
I referred to the 3rd edition. Your doubts are addressed on page 37. You can do either ways, as I said. Generally the more important object types are shown as a class box. So then you will need to connect the two with a line. If you do that, you do not need to show them as attributes in each other's box - that would be redundant information. You can show the primitive types (and some other lesser important objects) as attributes.
What is the full name of Cade's book?
Sun Certified Enterprise Architect for Java EE Study Guide by Mark Cade, Humphrey Sheil. Google it. This book was meant for the JEE 5 version of the test but you can still refer to chapter 9 and 10 as the assignment is common for OCMJEA 5 and 6.
Do you mean that in your example, "User Account" is a component in the component diagram?
No. At least not with that name. For example, you have some code in your project which deals with user authentication/user profile information. So "Generic User Logic" becomes your sub-system. And say, there is one SLSB -- that is the class where most of the user-fetching business logic is present, that SLSB could be a component in that sub-system. Now, there are a few helper classes for that SLSB - some have a business calculation or maybe some have SQL queries required by the main SLSB - those become the helper classes and they together can be a component. So your "Generic User logic" sub-system then has these two components. You should take a look at this example here:
UML Component diagram.
I hope this helped.
Aditya