CS365 Midterm 2

  1. This exam is open-note, open book.
  2. You must answer all of the questions.
  3. Answer all the questions on a separate sheet of paper.
  4. You must use Java to implement the coding questions.
  5. Good luck!

  1. (21 points) For each of the following questions choose the most appropriate response from the list of items below:
         a. Grid Layout       g. Box           m. JPanel     s. Visual Basic    y. Strategy
         b. GridBag Layout    h. JSlider       n. JMenu      t. Python          z. Observer
         c. Flow Layout       i. JButton       o. CGI        u. Ruby            aa. Listener
         d. Box Layout        j. JLabel        p. Perl       v. Java Script     bb. Singleton
         e. Border Layout     k. JTextField    q. XML        w. Recognition     cc. Algorithmic
         f. Spring Layout     l. JFrame        r. PhP        x. Recall          dd. Event
    1. ____________________ The scripting language most commonly used to implement CGI scripts.

    2. ____________________ The Java window object.

    3. ____________________ The language that uses a prototype-instance model.

    4. ____________________ Two different layout managers that can create grids with different width columns.

    5. ____________________ The type of design pattern used by the MVC model to notify views of changes in the model.

    6. ____________________ Radio buttons and check boxes take advantage of this type of human memory.

    7. ____________________ This scripting language can be embedded in an html specification to dynamically create html content.

    8. ____________________ This scripting language is designed by Microsoft but limited in its use to Microsoft products.

    9. ____________________ This layout manager is good for placing tool pallettes around the edges of a visual editor.

    10. ____________________ This Swing component has its own built-in layout manager that cannot be changed.

  2. (15 points) For each of the following user interface scenarios, choose from the following list the type of widget you think is most appropriate:

    1. _________________ You want the user to select an occuption from a set of 50 possible occupations.

    2. _________________ You want the user to select the number of bedrooms that they are interested in having in a house. The most bedrooms that a house can have is six.

    3. _________________ You want the user to select a font style. The possible options are bold, italic, underline, and oblique. They can select anywhere from zero to all four options.

    4. _________________ You want the user to enter their weight and are willing to accept any weight up to 1000 pounds.

    5. _________________ You want the user to specify a color by entering the values for red, green, and blue as integers between 0 and 100. The user should be able to rapidly change the values and see the current color immediately updated in a color swatch.

  3. (12 points) For each of the following situations choose the most appropriate scripting language from the below list:
    1. _________________ You are doing client side scripting and want your application to work in the maximum number of browsers.

    2. _________________ You are demonstrating an algorithm to a student and you want the student to be able to easily read your code.

    3. _________________ You are doing server side scripting and you do not want to endanger the security of your server.

    4. _________________ You want to take a formatted html page that contains information about the last 20 rounds of golf that have been played by a person, extract their scores, and compute their average score.

  4. (20 points) Write a fragment of Java code that creates 3 JButtons, named "Button1", "Button2", and "Button3", and one or more container objects to hold the buttons. It should add the JButtons to the container objects so that they are arranged as follows:

  5. (12 points) Suppose that you want to position a button using a GridBag Layout manager. The button should be laid out as follows:

    Set the appropriate parameters in the GridBag Constraint below to satisfy these requirements. Do not worry about any other parameters than the ones you need to satisfy the above set of requirements.
         GridBagConstraints c = new GridBagConstraints();

  6. (20 points) Write a perl script that will read lines from a file and if a line starts with a single letter from [a-z] followed by a period, changes the character and period to <li>. For example:
         a. slider
    should be changed to:
         <li> slider