X
  • quiz
    November 14, 2008

Tech Tips Quiz

Guest Author

Over the years, the Enterprise Java Technologies Tech Tips have covered a wide variety of enterprise Java technology topics.
Here's a short quiz that tests your knowledge of some topics covered in recent Tech Tips. You can find the answers at the end
of the quiz.


  1. True or false, you can attach validators, listeners, or a converter to composite user
    interface components in JavaServer Faces (JSF) 2.0 technology?

    a. True

    b. False

  2. Which of the following methods is used to guard against using stale data for computation in the Java Persistence API (JPA)
    on a versioned entity?

    a. Persistence.nonrepeat()

    b. EntityManager.lock()

    c. LockMode.set()

    d. None of the above

  3. What is Phobos?

    a. A framework for enabling interoperable web services.

    b. A lightweight, scripting-friendly, web application environment that runs on the Java platform.

    c. A container for JavaScript widgets.

    d. An debugger for the NetBeans IDE that provides advanced analysis features.

    e. An MBean generator.

  4. Which of the following mechanisms are available through the NetBeans IDE to
    secure Metro-based web services:

    a. Username Authentication with Symmetric Keys

    b. SAML Authorization over SSL

    c. STS Issued Endorsing Token

    d. All of the above

    e. None of the above

  5. A Jersey 1.0-based web application returns status information about print jobs. The application
    uses JAXB beans to model the printer status information. The application transforms the status data
    from its JAXB specification to JSON notation. Here is printer status data as specified in a JAXB bean:
       @XmlRootElement
    public class StatusInfoBean {
    public String status = "Idle"
    public int tonerRemaining = 25;
    }

    If the application uses Jersey 1.0 to transform the status data into the mapped type of JSON notation,
    what will the JSON-formatted data look like?


    a.{"StatusInfoBean":{"status":"Idle","tonerRemaining":"25"}}

    b.{"status":"Idle", "tonerRemaining":"25"}

    c.{"StatusInfoBean":{"status":{"$":"Idle"},"tonerRemaining":{"$":"25"}}}

    d.{"status":{StatusInfoBean":[{"status":"Idle","tonerRemaining":"25"}]

Answers


  1. True or false, you can attach validators, listeners, or a converter to composite user
    interface components in JavaServer Faces (JSF) 2.0 technology?

    a. True

    b. False

    a. True. This feature in JSF 2.0 allows you to turn any collection of page markup into a JSF user interface (UI)
    component -- with attached validators, converters, action listeners, and value change listeners -- for use
    by page authors. Unlike composite components created with other approaches such as Facelets, composite
    components in JSF 2.0 technology support all the features of a real UIComponent.
    To learn more about composite UI components in JSF 2.0, see the August 29, 2008 Tech Tip
    True
    Abstraction: Composite UI Components in JSF 2.0 -- Part 1
    and the September 15, 2008 Tech Tip

    True Abstraction: Composite UI Components in JSF 2.0 -- Part 2
    .


  2. Which of the following methods is used to guard against using stale data for computation in the
    Java Persistence API (JPA) on a versioned entity?

    a. Persistence.nonrepeat()

    b. EntityManager.lock()

    c. LockMode.set()

    d. None of the above

  3. b. EntityManager.lock(). Stale data means data that is no longer current. Guarding against
    using stale data for computation in the Java Persistence API (JPA) on a versioned entity means preventing
    situations such as the following:



    Transaction T1Transaction T2
      tx1.begin();
    d1 = findDepartment(dId);
    //d1's original name is "Engrg"
    d1.setName("MarketEngrg");
    tx1.commit();
      tx2.begin();
    e1 = findEmp(eId);
    d1 = e1.getDepartment();
    if(d1's name is "Engrg")
    e1.raiseByTenPercent();
    tx2.commit();

    In this situation, transaction T2 checks employee e1s version in the database,
    but does not check employee d1s version because it doesn't see d1
    as "dirty". Transaction T2 doesn't make the d1 check even though it uses
    d1s version in its computation. As a result, employee e1 gets an undeserved raise.
    One way to prevent this situation is to use the lock() method of the EntityManager class.
    This method sets the lock mode, READ or WRITE, for an entity object contained in the persistence context.
    If the lock mode is READ, the entity manager protects against dirty reads or non-repeatable reads.
    If the lock mode is WRITE, it forces an update to the entity's version column.

    Another approach is to use pessimistic locking. In pessimistic locking, all transactions occur in a completely isolated fashion, that is, as if all transactions in the system had executed serially, one after the other. A read transaction locks the row representing the data in the underlying datasource. A write transaction can commit only after the read commits. During the read transaction, the value of the data being locked does not change.

    For more information about preventing the use of stale data in JPA, see the July 2, 2008 Tech Tip,
    Preventing Non-Repeatable
    Reads in JPA Using EclipseLink
    .


  4. What is Phobos?

    a. A framework for enabling interoperable web services.

    b. A lightweight, scripting-friendly, web application environment that runs on the Java platform.

    c. A container for JavaScript widgets.

    d. An debugger for the NetBeans IDE that provides advanced analysis features.

    e. An MBean generator.

    b. A lightweight, scripting-friendly, web application environment that runs on the Java platform.
    Using Phobos, you can take advantage of
    the benefits offered by scripting languages and leverage
    the power of the Java platform. Being scripting-friendly, Phobos provides a programming environment
    that fosters rapid application development. The primary language supported by Phobos is JavaScript,
    which Phobos supports using the Mozilla Rhino scripting engine.
    To learn more about Phobos and see an example of its use with
    jMaki, see the August 12, 2008 Tech Tip
    Building An
    Ajax-Enabled Web Application Using Phobos and jMaki
    .


  5. Which of the following mechanisms are available through the NetBeans IDE to
    secure Metro-based web services:

    a. Username Authentication with Symmetric Keys

    b. SAML Authorization over SSL

    c. STS Issued Endorsing Token

    d. All of the above

    e. None of the above

    d. All of the above. The NetBeans IDE offers an easy way to enable security using the
    Metro web services
    stack of technologies. One of the ways it does this is by providing a set of security profiles that specify the
    mechanism to be used in securing conversations. The NetBeans IDE offers a variety of security profiles to choose
    from, three of which are Username Authentication with Symmetric Keys, SAML Authorization over SSL, and STS Issued Endorsing Token.
    Four of the security profiles offered by the NetBeans IDE (STS Issued Token, STS Issued Token with Service Certificate,
    STS Issued Endorsing Token, and STS Issued Supporting Token) secure web services with Security Token Service (STS)-issued
    tokens. This enables secure conversations with Metro-based web services in accordance with the WS-Trust security
    specification. For more information about security profiles and support for WS-Trust in Metro, see the October 14, 2008
    Tech Tip, Using WS-Trust Support in Metro
    to Secure Web Services
    .


  6. A Jersey 1.0-based web application returns status information about print jobs. The application
    uses JAXB beans to model the printer status information. The application transforms the status data
    from its JAXB specification to JSON notation. Here is printer status data as specified in a JAXB bean:
       @XmlRootElement
    public class StatusInfoBean {
    public String status = "Idle"
    public int tonerRemaining = 25;
    }

    If the application uses Jersey 1.0 to transform the status data into the mapped type of JSON notation,
    what will the JSON-formatted data look like?


    a.{"StatusInfoBean":{"status":"Idle","tonerRemaining":"25"}}

    b.{"status":"Idle", "tonerRemaining":"25"}

    c.{"StatusInfoBean":{"status":{"$":"Idle"},"tonerRemaining":{"$":"25"}}}

    d.{"status":{StatusInfoBean":[{"status":"Idle","tonerRemaining":"25"}]

    b.{"status":"Idle", "tonerRemaining":"25"}.
    Jersey 1.0 is an open-source, production-ready reference implementation
    of JAX-RS, the Java API for RESTful Web Services (JSR-311).
    Jersey makes it easy to create RESTful web services in Java. JSON (JavaScript Object Notation) is a lightweight data-interchange
    format that is based on the object notation of the JavaScript language. Because of it's simple text format, JSON provides
    a good alternative to other data interchange formats such as XML and is particularly attractive as a data interchange format
    for RESTful web services.

    Jersey 1.0 can generate three types of JSON notation from JAXB beans: mapped format, Jettison format,
    and BadgerFish format. You specify the type of format in a JAXB context resolver using the JSONJAXBContext.JSON_NOTATION
    parameter. For example, JSONJAXBContext.JSONNotation.MAPPED specifies the mapped format, which is also the default
    format. Answer b represents the printer status data in mapped format. Answer a represents the printer status data in
    Jettison format. And answer c represents the printer status data in BadgerFish format. Answer d does not correspond to any format
    supported by Jersey 1.0. For more information about support for JSON in Jersey 1.0, see the October 27, 2008
    Tech Tip, Configuring JSON for RESTful
    Web Services in Jersey 1.0
    .



Join the discussion

Comments ( 6 )
  • guest Wednesday, November 19, 2008

    Nice


  • ali hamedi Wednesday, November 19, 2008

    thank myou


  • Sanjeev Kulkarni Thursday, November 20, 2008

    Thanks a lot.Got some thing to learn from...


  • rahil Wednesday, November 26, 2008

    Should have a quiz like this every month.


  • Edward Ort Wednesday, November 26, 2008

    You might want to check developers.sun.com. They post new quiz questions frequently.


  • Replica gucci handbags Monday, December 21, 2009

    Very good collection of information


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.