Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

Quiz

Review today’s material by taking this three-question quiz.

Questions

1.

What does RSS stand for?

  1. Really Simple Syndication
  2. RDF Site Summary
  3. Both
2.

What method cannot be used to add text to an XML element using XOM?

  1. addAttribute(String, String)
  2. appendChild(Text)
  3. appendChild(String)
3.

When all the opening element tags, closing element tags, and other markup are applied consistently in a document, what adjective describes the document?

  1. Validating
  2. Parsable
  3. Well-formed

Answers

1.

c. One version, RSS 2.0, claims Really Simple Syndication as its name. The other, RSS 1.0, claims RDF Site Summary.

2.

a. Answers b. and c. both work successfully. One adds the contents of a Text element as the element’s character data. The other adds the string.

3.

c. For data to be considered XML, it must be well-formed.

Certification Practice

The following question is the kind of thing you could expect to be asked on a Java programming certification test. Answer it without looking at today’s material or using the Java compiler to test the code.

Given:

public class NameDirectory {
    String[] names;
    int nameCount;

    public NameDirectory() {
        names = new String[20];
        nameCount = 0;
    }

    public void addName(String newName) {
        if (nameCount < 20)
            // answer goes here
    }
}

The NameDirectory class must be able to hold 20 different names. What statement should replace // answer goes here for the class to function correctly?

  1. names[nameCount] = newName;
  2. names[nameCount] == newName;
  3. names[nameCount++] = newName;
  4. names[++nameCount] = newName;

The answer is available on the book’s website at http://www.java21days.com. Visit the Day 19 page and click the Certification Practice link.

  • + Share This
  • 🔖 Save To Your Account