Scripting Languages Final Exam

  1. This exam is open-note, open-book. However, no electronic devices may be used
  2. You have two hours to complete the exam
  3. Do not worry about surrounding your javascript code with "script" tags or your PHP code with "<?php" tags
  4. This exam has 10 questions. You must complete all 10 questions.
  5. Good luck!


  1. 14 points: Fill in the blanks for the following questions:

    1. _____________________ The type of object you create in Javascript to make an Ajax request

    2. _____________________ The event that gets triggered by Ajax when the server finishes processing a request (it is fine to give the property name that you set in a Javascript object)

    3. _____________________ In what format should the server returns its response to Javascript (based on what was discussed in class)

    4. _____________________ If you need to create an XML document using PHP, which XML parser should you use?

    5. _____________________ If you have an XML document that you want to process using PHP but it is too big to fit completely in memory, which XML parser should you use?

    6. _____________________ If you have an XML document that can fit in memory and you simply want to access information from the document but not change it, which XML parser should you use?

    7. _____________________ What pattern-based feature of Perl makes extracting data from files so simple? This feature can also make type checking data relatively simple.

  2. 10 points: Choose the best answer from the following set of choices:

    compiled language, like CHTMLCSS
    XMLSQLXPath
    PerlJavascriptPhP
    DTDSchemaRegular Expressions

    1. ________________ Uses the prototype-instance model
    2. ________________ Helpful for specifying patterns for type checking data
    3. ________________ Specifies the structure of an XML document but not the data types of the elements' contents
    4. ________________ A common public source database server.
    5. ________________ Easily generates dynamic html pages
  3. 10 points: In cascading style sheets, explain what is meant by the cascade and explain the factors that help determine the cascade. Use no more than 5 sentences.

  4. 9 points: Describe three limitations of javascript that make it unsuitable for either general purpose computing or server side applications. Conversely, for each limitation describe why it makes javascript a more suitable language for client side applications or why the designers felt the limitation did not affect Javascript's ability to implement client side applications. Use no more than 5 sentences.

  5. 5 points: What feature of Perl made it become so popular with system administrators? Why did this feature make system administrators' lives so much easier? Use no more than 5 sentences.

  6. 8 points: Describe two ways in which the prototype-instance model differs from the class-instance model. Use no more than 5 sentences.

  7. 12 points: In 3 sentences or less describe two different potential applications where you might want to use AJAX, and then in 4 sentences or less describe what parts of the application would use AJAX. Be specific. For example, I might say that I want to use AJAX for a stock ticker application and that I would use AJAX to query the server every 10 seconds for the current market price of each stock in the user's portfolio and then update the price of the stock on the user's web page (and no you cannot use a stock application as one of your two examples).

  8. 12 points: Suppose you have the following html form: <form name="tax" method="POST"> <input type="text" name="amount" maxlength="8"><br> <input type="text" name="taxrate" maxlength="4"><br> <input type="text" name="salestax" maxlength="5"><br> </form> Write a javascript fragment that calculates the sales tax amount as:
    sales tax = amount * taxrate
    
    and stores the result in the salestax form element. You will need to extract the amount and taxrate values from their respective form elements. If the sales tax amount is more than $50 then the amount should be shown in red, otherwise the amount should be shown in the normal black color.

  9. 5 points: In the above question, suppose that instead of a text form element for sales tax, I had the following html element:
    sales tax: <span id="tax">0<span>
    
    Show me the javascript statement that you would now need to use in order to display the result of the sales tax computation. For this question, do not worry about showing the amount in red if the tax amount is more than $50. All I care about is the statement that alters the content of the html page.

  10. 15 points: Assume you have the following table structure:

    Questions
    CourseQuestionTextOption1Option2Option3Option4Answer
    CS302"What city is the flagship UT campus located in?" 204205240241240

    Options
    OptionIdOptionText
    204Nashville
    240Knoxville

    Assume that the database is named "questions", that the database server is "schools.com", that the user id is "cs460" and that the password is "correct".

    1. Write a PHP fragment that connects to the server and selects the database

    2. Write an SQL query that selects the question text and answer ids for all questions associated with CS302

    3. Write an SQL query that selects the question text and answer text for all questions associated with CS302. In the above example, the question text would be "What city is the flagship UT camplus located in?" and the answser text would be "Knoxville".