Fina Review Questions 2 with Answers Omit 1. How many bytes are in a gigabyte? Ans: 2^30 = 1,073,741,824. 2. Give the rgb color codes for these colors: aqua, gray, maroon, yellow. Ans: aqua = (0,255,255); maroon = (128,0,0); yellow = (255,255,0). Omit 3. What is the difference between resizing and cropping images with MS Paint? Ans: Resizing means keeping the same image, but making it smaller by reducing the number of pixels. Cropping means extracting a rectangular portion of the image. 4. Write an image tag to display the image mouse.jpg, resized to 180 by 240 pixels. Ans: 5. What is the HTML source code that displays literally this end tag: Ans: </html> 6. Rewrite this HTML code using an inline style instead: abc def ghi Ans: abc def ghi 7. Write a document-level style that sets the style for the each paragraph of an HTML page with these specifications: a) Arial font b) Blue text color c) 10 point font size d) Background color beige e) First line indented by 10 millimeters Ans: p { font-family:arial; color:blue; font-size:10pt; background-color:beige; text-indent: 10mm; } omit 8. Write a user defined class named angry in a document-level style that displays text in red, Forte font and 130% larger than usual. Here is an example of the tag's usage: I am very upset with you.

Ans: .angry { color:red; font-family:forte; font-size:130%; } 9. Write an HTML/JavaScript application that inputs the height in feet and inches, then converts this height to centimeters. The conversion factor is 2.54cm per inch. You will need two input textboxes, one output textbox and a submit button.
Feet
Inches
Centimeters

10. Write a JavaScript script that displays the following on an HTML page: Your lucky number is 45. 45 is a random number in the range 1, 2, ..., 99, 100. Use document.write to write to the page. Ans: document.write(1 + Math.floor(100 * Math.random( )); 11. Write a JavaScript statement that changes the background color of the page to AliceBlue. Ans: document.bgColor = "AliceBlue"; 12. Write a JavaScript statement that displays 2 to the 30th power in the status bar of the browser. Ans: window.status = Math.pow(2, 30); 13. Write HTML code for these two controls: a. A button with text Push Me, width 1.5 inches, height 0.75 inches, background color silver, text color maroon and event handler function ButtonEventHandler. Ans: b. A textbox with width 1.5 inches, height 0.75 inches, background color beige, text color navy and font Verdana. Ans: 14. Construct the variable trace and predict the output: var a = 4, b = 7, c = "s"; a = a + 3 * b; b = 2 * a + b; c = c + b + a; a = 2 * a; b = b + 3; c = c + c; document.write(a + " " + b + " " + c); Ans: a b c =====+=====+============= Output: 4 7 "s" 50 60 "s5725s5725" 25 57 "s5725" 50 60 "s5725s5725" 15. Find the mistakes in the following code: body = "backColor:130, 255, 60; color:White; font:ariel; } <script> function FF { documents.frmMain.RV = Math.Random( ); <head> <body> <p> <img sourc="lotto.GIF " > </p> <p> <input type="textbox" name="txtRV" value='' size=10 > <p/> <p> <input type="button" name="btnSubmit" value='Show Random' onclick="ShowRandom( );" /> <p/> </script> <body /> </html> Ans: Corrected code: <head> <title>Display a Random Number between 0 and 1
Painting Plumbing Electrical

Total Bill:

31. Write a JavaScript function that will display a slideshow (sequential or random) consisting of the 3 images dog.jpg, cat.jpg and mouse.jpg. Display the images in the image named imgAnimal on the form frmSlideShow. var n = 0; function StartSlideShow( ) { if (n == 1) { document.images.imgAnimal.src = "dog.jpg"; } else if (n == 2) { document.images.imgAnimal.src = "cat.jpg"; } else if (n == 3) { document.images.imgAnimal.src = "mouse.jpg"; } n = n + 1; if (n == 4) { n = 1; } } omit 32. Write HTML code to display three radio buttons with captions Discover, MasterCard and Visa. The radio buttons should be in a group so that only one can be checked at a time. Ans:

Discover

MasterCard

Visa

33. Write HTML code to display a drop down menu with entries DePaul, Loyola, Roosevelt. Ans: 34. Write a JavaScript function that displays the selected item of the drop down menu in the preceding problem. Display the selected item in a alert box. Ans: function DisplaySelectedItem( ) { window.alert(document.frmMain.ddmUniversity.value); } omit 35. Write a JavaScript function code to display a text area with name taComments on a page with the initial text "Enter comments here." Ans: omit 36. Write a JavaScript function that copies the string from taComments to the textbox txtSave. Ans: function CopyComments( ) { document.frmMain.txtSave.value = document.frmMain.taComments.value = } 37. Write a submit button that performs the action in the preceding problem and then submits the page to the server. Ans: 38. Write a form tag that submits the page to the server site site "http://www.the-server.org". Ans: