|CIT597 Quiz 1
Please keep all answers short and to the point. Read each question and answer
it; don't add information that wasn't asked for.
x is a double variable, write a simple assertion
x is greater than zero and less than
assert x > 0 && x < y; // A single & would also work
- Write the same assertion as in the previous question, but this time include
the values of
y in the detail
message of the AssertionError that may be thrown.
assert x > 0 && x < y: "x = " + x + " y
= " + y; // But not x + y
- Write the Java statement that creates a Pattern from the String
Pattern p = Pattern.compile("a(.*)b(.*)c(.*)d");
// OK to just start with p =
- Write the Java statement that creates a Matcher for the String
using the Pattern defined in the previous question.
Matcher m = p.matcher(p);
// OK to just start with m =
- Using the above Matcher, does
find() succeed? If so,
what is returned by each
for each legal value of
group(0) = "abracad" group(1) = ""
group(2) = "ra" group(3)
- Write a regular expression that will succeed (using
on the string
"abracadabra" and will return
everything between the two
- Name two elements that you should always find within an HTML
tr, td (or <tr>, <td>)
- What HTML would you write to draw a horizontal line across the page?
<hr> (or <hr width="100%">)
- What HTML would you write to make the entire background of your document
a bright red?
<body bgcolor="red"> or <body bgcolor="#FF0000">
// quotes not important in HTML
- Name two HTML tags that are not containers.
<hr>, <img>, possibly others--but not <a>
- What attribute is required in an
src // This is the only required tag
- List two (and only two) of the ways in which XHTML is stricter than HTML.
- Two of: tag names must be lowercase, attributes must be lowercase,
attributes must be quoted, everything is properly nested, all attributes
must have values
- id replaces name // incorrect but I'll accept it
- There are three versions of XHTML. Name two (and only two) of them.
Two of: strict, transitional, frameset
- HTML and XML are designed for different purposes. Briefly, what
is the purpose of each?
- HTML: Designed to display information to humans
- XML: Designed to provide data to computers
- What organization defines the standards for HTML, XHTML, and XML?
World Wide Web Consortium // W3C is enough
- What does it mean to say that an XML document is valid?
It conforms to a DTD // or some other kind of schema
- Briefly tell what each of the following symbols means in a DTD:
+ (plus sign) One or more
* (asterisk) Zero or more
? (question mark) Optional (zero or one)
| (vertical bar) Alternatives (choose one)
, (comma) Things must be in the order specified
- Suppose an XML document consists of just a list of cartoon characters. Each
character has a name and a species, for instance, Sylvester
is a cat; Tweety is a bird.
- Write a short but complete XML document that lists these two cartoon
characters. Don't forget the XML header.
- Write a DTD that describes this document. Make it general enough that
we can add other cartoon characters (of other species) later. //
OK to use attributes
<!ELEMENT characters (character+)>
<!ELEMENT character (name, species)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT species (#PCDATA)>