CS290w EXAM 1
Thursday, October 15, 1998



Advanced HTML

(1) Which of the following causes a heading to be aligned left?
(a) <H1 LEFT>
(b) <H2 ALIGN=CENTER>
(c) <LEFT H3>
(d) <H3>
D

(2) Which is true about mailto?
(a) mailto is used in place of HREF, that is <A MAILTO="">
(b) Only one email address may be used.
(c) 1-5 email addresses may be used.
(d) Some email clients place comma-separated items on separate To: lines.
D

(3) In...
<OL TYPE=I>
<LI> oranges
<LI> peaches
<LI> grapes
<LI> apples
<LI> raisins
</OL>
... what characters will preceed each list item entry?
(a) i, ii, iii, iv, v
(b) I, II, III, IV, V
(c) 1, 2, 3, 4, 5
(d) A, B, C, D, E
B

(4) In...
<OL TYPE=A START=4>
<LI> oranges
<LI> peaches
<LI VALUE=2> grapes
<LI> apples
<LI> raisins
</OL>
... what character will preceed "apples"?
(a) 3
(b) C
(c) 7
(d) G
B

(5) What is the difference between the <PRE> and <XMP> tags?
(a) HTML tags are honored inside the <PRE>, but ignored inside the <XMP>.
(b) HTML tags are ignored inside the <PRE>, but honored inside the <XMP>.
(c) No difference at all.
(d) The <XMP> tag works exactly like the <CODE> text tag.
A

(6) Why was the &nbsp; tag created?
(a) To make paragraphs begin at the left margin
(b) To keep words together on one line
(c) To use inside the <PRE> tag for extra spaces
(d) To use instead of the <XMP> tag
B

(7) mom.gif is an image that is 200 pixels wide and 150 pixels high. The image tag is <IMG SRC="images/mom.gif" WIDTH=400>. What will be the width and height in pixels of mom.gif as it is displayed?
(a) 200x150
(b) 400x300
(c) 400x150
(d) 400x200
B

(8) What happens if the <BODY> includes both BACKGROUND and BGCOLOR attributes?
(a) Because this is ambiguous, neither the BACKGROUND nor the BGCOLOR will be displayed.
(b) The BGCOLOR will be displayed first and replaced by the BACKGROUND image when it arrives.
(c) The BGCOLOR will not be displayed. That is, BACKGROUND takes precedence.
(d) The BACKGROUND will not be displayed. That is, BGCOLOR takes precedence.
B

(9) How does the TABLE <CAPTION> differ from any text that you might put just before or just after a table?
(a) The CAPTION appears inside the BORDER of the table.
(b) Lines of the CAPTION will be adjusted to conform to the width of the table.
(c) ALIGN=LEFT or ALIGN=RIGHT text will wrap around the table, but not the CAPTION.
(d) No difference.
B

(10) The BGCOLOR attribute can be used to change background color with all the following TABLE tags except one. Which one?
(a) TABLE
(b) CAPTION
(c) TR
(d) TH
B

(11) For what is VALIGN an abbreviation?
(a) VALue to IGNore
(b) Virtual ALIGNment
(c) Visual ALIGNment
(d) Vertical ALIGNment
D

(12) What does the following mean...?
<META HTTP-EQUIV="Refresh" CONTENT=60>
(a) Load another page from the server in 60 seconds
(b) Reload a maximum of 60 copies of this page
(c) Reload copies of this page from the server every 60 seconds
(d) Reload a copy of this page from the server in 60 seconds
D

(13) What does the following mean...?
<FRAMESET COLS="85,*">
(a) There are two columns -- each of 85 pixels.
(b) The first column is 85 pixels. The second column is the remainder of the framed area.
(c) The first column is 85% and the second column is 15% of the framed area.
(d) The first column is 85 pixels. There is no second column.
B

(14) Which of the following is true about naming (NAME=) frames?
(a) All frames must be named.
(b) Only one frame of a FRAMESET can be named.
(c) A frame is usually named only if some other frame needs to refer to it.
(d) Any frame can be named "_top".
C

(15) Which of the following best describes Client Side and Server Side Image Maps?
(a) With a Client Side Image Map, the browser decides what URL to request for any given click.
(b) With a Server Side Image Map, the browser decides what URL to request for any given click.
(c) Both Client and Server Side Image Maps handle CIRCLE areas in exactly the same way.
(d) Both Client and Server Side Image Maps use the ISMAP attribute.
A

(16) Which of the following best describes CHECKBOXes and RADIO buttons?
(a) Multiple CHECKBOXes of the same group can be selected simultaneously. (b) Multiple RADIO buttons of the same group can be selected simultaneously. (c) The only difference between CHECKBOXes and RADIO buttons are the shape of the image used by the browser to display them.
(d) Each form can have only one set of RADIO buttons.
A

(17) What term refers to a program run by the Web browser?
(a) application
(b) applet
(c) servlet
(d) cgi-bin
B

(18) You do not need a SUBMIT button in order for users to submit the contents of a form if you have...?
(a) a RESET button
(b) only one SELECT tag
(c) only one TYPE=TEXT tag
(d) SIZE=1
C

JavaScript

(19) What is a JavaScript function?
(a) set of statements that perform some task
(b) if...else, switch, for, while, do...while
(c) dynamic HTML
(d) event handler
A

(20) Which of the following JavaScript statements is like a multi-branch (3 or more branches) if statement?
(a) switch
(b) for
(c) if...else
(d) do...while
A

(21) Where can JavaScript code appear in an HTML file?
(a) FORM only
(b) BODY only
(c) HEAD only
(d) HEAD and BODY
D

(22) Where do JavaScript function definitions usually appear in the HTML file?
(a) HEAD
(b) HREF
(c) FORM
(d) TITLE
A

(23) Which statement below will show on the displayed page the date the document was last changed?
(a) document.lastModified();
(b) document.write(document.title));
(c) document.write(document.lastModified));
(d) lastModified();
C

(24)
function decr (number)
{
return (number - 1);
}
Which statement below will show on the displayed page a number TWO LESS than the variable many?
(a) document.write(many, -2);
(b) document.write(decr(many));
(c) document.write(decr(decr(many)));
(d) document.write(decr(decr(many-2)));
C

(25)
function rule(width, extra)
{
document.write("<HR ALIGN=LEFT WIDTH=" + width
+ "% " + extra + ">");
}
Which statement below will show on the page a horizontal rule half the width of the page with no shading?
(a) rule (50, "NOSHADE");
(b) rule (50, "SIZE=5");
(c) rule (50, "");
(d) rule ("NOSHADE", 50);
A

(26) Which statement below will pop up a prompt box that requests an ID number, but has no number already in the response field?
(a) prompt("", "Enter your ID number:");
(b) prompt("Enter your ID number:", "99999");
(c) prompt("Enter your ID number:", "0");
(d) prompt("Enter your ID number:", "");
D

(27) Which statement below will only submit a form's content if the user presses the Confirm box "OK" button?
(a) confirm('Are you sure?')
(b) onSubmit="confirm('Are you sure?')"
(c) onSubmit="return(confirm('Are you sure?'))"
(d) onSubmit=""
C

(28)
setTimeout(rhumba(place), 30000);
What does the statement above do?
(a) waits 30 seconds and then calls function rhumba
(b) calls function rhumba every 30 seconds
(c) calls function rhumba and then waits 30 seconds before doing anything else (d) calls function rhumba a maximum of 30,000 times
A

(29) Which of the following statements when executed redirects the client to another URL as if the user had clicked on a hyperlink?
(a) HREF = "http://www.netnanny.com";
(b) location = "http://www.netnanny.com";
(c) http://www.netnanny.com;
(d) <A HREF="http://www.netnanny.com">;
B

(30) Suppose the following appears in an HTML file:
<SCRIPT LANGUAGE="JavaScript">
window.innerWidth=450;
window.innerHeight=250;
</SCRIPT>
What happens?
(a) The size of the window in which this file is being viewed is changed so that the viewing area is 450x250 pixels.
(b) Text in the Web page reports the innerWidth and innerHeight of the window.
(c) The next HREF clicked-on will be viewed in a window with viewing area of 450x250 pixels.
(d) The size of the window in which this file is being viewed is changed so that it is 450x250 pixels (including buttons and scrollbars).
A

(31) If a Web page contains only the following form...
<FORM>
<INPUT TYPE=TEXT NAME=move SIZE=20>
<INPUT TYPE=TEXT NAME=over SIZE=20>
<INPUT TYPE=PASSWORD NAME=secret SIZE=20>
<INPUT TYPE=SUBMIT VALUE="Submit">
<INPUT TYPE=RESET>
</FORM>
...to what does document.forms[0].elements[3] refer?
(a) the Password field
(b) the Submit button
(c) the Reset button
(d) the Text field named "over"
B

(32) You have created a JavaScript function named validate that examines several values in a form and returns true if the form is to be submitted or false otherwise. In the FORM tag...
<FORM ... onSubmit="return(validate(__________))">
...what should go in the blank?
(a) this
(b) this.form
(c) this.button
(d) this.form.firstname.value
A

(33) You have created a JavaScript function named checkout that examines several values in a form. In the INPUT tag...
<INPUT TYPE="button" ... onClick="checkout(__________)">
...what should go in the blank?
(a) this
(b) this.form
(c) this.button
(d) this.form.firstname.value
B

(34)
<A HREF="..." OnMouseOver="overeggs()" OnMouseOut="offeggs()">
<IMG SRC="images/eggs.gif" name="oval"></A>
Given the HTML and JavaScript above, what line in function overeggs would change the appearance of SOME OTHER image in this file?
(a) document.oval.src = "images/eggs.gif";
(b) document.oval.src = "images/ham.gif";
(c) document.oval.src = "images/bacon.gif";
(d) document.ham.src = "images/bacon.gif";
D

(35) Which of the following will pop-up an alert box that says "I can't complain"?
(a) OnMouseOver="alert(I can't complain)">
(b) OnMouseOver="alert("I can't complain")">
(c) OnMouseOver="alert('I can't complain')">
(d) OnMouseOver="alert('I can\'t complain')">
D

(36) What is the difference between the onBlur and onChange event handlers?
(a) onBlur may only be called if there is also an onFocus event handler. onChange may be called even if there is no onFocus event handler.
(b) onChange is called whenever an element loses focus. onBlur is called whenever an element that has been changed loses focus.
(c) onBlur is called whenever an element loses focus. onChange is called whenever an element that has been changed loses focus.
(d) Trick Question: They are equivalent.
C

(37)
government=window.open ("http://www.whitehouse.gov", "execbranch",
"height=300,width=500,location=yes,toolbar=no,
scrollbars=yes")
Which of the following hyperlinks opens in the window above?
(a) <A HREF="..." TARGET="window">
(b) <A HREF="..." TARGET="whitehouse">
(c) <A HREF="..." TARGET="government">
(d) <A HREF="..." TARGET="execbranch">
D

(38)
<FRAMESET ROWS="50%,50%">
<FRAMESET COLS="50%,50%">
<FRAME SRC=category.html>
<FRAME SRC=titles.html>
</FRAMESET>
<FRAMESET COLS="50%,50%">
<FRAME SRC=authors.html NAME="writers">
<FRAME SRC=publishers.html>
</FRAMESET>
</FRAMESET>
Which of the following functions will change the contents of the upper right and lower left frames?
(a)
function reframe()
{
top.frames[1].location="books.html";
top.writers.location="new.html";
}

(b)
function reframe()
{
top.frames[2].location="books.html";
top.frames[3].location="new.html";
}

(c)
function reframe()
{
top.frames[1].location="books.html";
top.frames[3].location="new.html";
}

(d)
function reframe()
{
top.frames[0].location="books.html";
top.authors.location="new.html";}

A

(39) How do you call the reframe() function from the question above in a hyperlink reference?
(a) <A HREF="reframe">New Books</A>
(b) <A HREF="reframe()">New Books</A>
(c) <A HREF="javascript:reframe()">New Books</A>
(d) <INPUT TYPE="button" VALUE="New Books" onClick="reframe()">
C

(40)
status="Mark McGwire and Sammy Sosa";
What does the line above do?
(a) Nothing, because it should say status='Mark McGwire and Sammy Sosa';
(b) Displays the character string "Mark McGwire and Sammy Sosa" in the status bar
(c) Scrolls the character string "Mark McGwire and Sammy Sosa" in the status bar every 20 seconds
(d) Displays the character string "Mark McGwire and Sammy Sosa" in an alert box
B

(41) The statements...
var pic1=new Image();
pic1.src="images/monkey.gif";
...can be used to pre-load images if they appear where?
(a) inside a JavaScript function
(b) inside <SCRIPT LANGUAGE="JavaScript">...</SCRIPT> but not inside a JavaScript function
(c) inside <XMP>...</XMP>
(d) Trick question. Pre-loading of images is not possible with JavaScript.
B

Java

(42) What is the Java Development Kit (JDK)?
(a) a set of software tools that allow you to compile and debug Java applets
(b) the component of every Web browser that is able to interpret Java Byte Code
(c) the Java Appletviewer
(d) a set of software tools that are only available for the Sun workstation
A

(43) Which of the following is NOT a possible result of running the following command?
javac Morph.java
(a) A file named Morph.html is created.
(b) A file named Morph.class is created.
(c) Several Java error messages appear.
(d) The system cannot find javac or Morph.java.
A

(44) Which of the following will display the applet from the preceding question?
(a) <APPLET CODE="Morph" WIDTH=500 HEIGHT=800>
(b) <APPLET CODE="Morph.java" WIDTH=500 HEIGHT=800>
(c) <APPLET CODE="Morph.html" WIDTH=500 HEIGHT=800>
(d) <APPLET CODE="Java" WIDTH=500 HEIGHT=800>
A

(45) What does JDK's appletviewer show?
(a) An applet's source code
(b) All text, images, and applet(s) on a Web page
(c) Just the applet(s) on a Web page
(d) Suggestions for fixing errors that were found when running javac
C

(46) Why do we say that Java is both compiled and interpreted?
(a) Because the .java file is compiled to make a .class file which will later be interpreted
(b) Because Web browsers have both Java compilers and Java interpreters
(c) Because javac is both a Java compiler and a Java interpreter
(d) If we said that, we would be wrong!
A

(47) What does a Java Virtual Machine (JVM) do?
(a) Interprets Java ByteCode
(b) Works with a .java file
(c) "Reverse engineers" a .class file to produce the original .java file
(d) Produces Java ByteCode
A

(48) What does the line
import java.awt.*;
in a Java program mean?
(a) import all the classes from the Abstract Window Toolkit
(b) import the class named * from the Abstract Window Toolkit
(c) import only one class (to be named below) from the Abstract Window Toolkit
(d) import java.applet.*
A

(49) Which of the following is appropriate for the java file mentioned in question (43)?
(a) public class java extends Applet
(b) public class Morph extends Applet
(c) public class Morph.java extends Applet
(d) public class Welcome extends Applet
B

(50) What is the file name you MUST use if the file contains the line:
public class Ripple extends Applet
(a) Ripple.applet
(b) Ripple.class
(c) Ripple.java
(d) Ripple.html
C

(51) What method is automatically called by any applet object to initialize itself?
(a) add
(b) paint
(c) initialize
(d) init
D

(52) What method is used to paste things into applets?
(a) add
(b) paste
(c) init
(d) paint
A

(53) What happens if you use the line
import java.applet.Applet;
at the top of a Java program?
(a) You will get an error message from javac. This line should be import java.applet.*;
(b) It imports all classes (AppletContext, AppletStub, AudioClip) from the applet package EXCEPT Applet
(c) It imports all classes (Applet, AppletContext, AppletStub, AudioClip) from the applet package
(d) It imports the Applet class from the applet package
D

(54) In the line
g.drawString("Press the button for more information",
41, 57);
which best describes the two numbers 41 and 57?
(a) Only the first 41 characters of the string "Press the button for more information" appears.
(b) Only the first 57 characters of the string "Press the button for more information" appears.
(c) The string "Press the button for more information" is placed in a text field of 41 characters, for a maximum 57 characters.
(d) The string "Press the button for more information" is drawn at x-coordinate 41 and y-coordinate 57.
D

(55)
Label caption;
caption = new Label("Stocks and Bonds");
add(caption);
Which of the following is the most equivalent to the three lines above?
(a) add(new Label);
(b) add("Stocks and Bonds");
(c) add(Label caption = new Label("Stocks and Bonds"));
(d) Label caption; add(caption);
C

(56) Which of the following will cause a label named myLabel to appear with a white background?
(a) myLabel = new Label("Color.white");
(b) setBackground.myLabel(Color.white);
(c) myLabel.setBackground;
(d) myLabel.setBackground(Color.white);
D

(57) Which of the following will cause a button named bookBind to have the text on the button appear in green?
(a) setForeground(Color.green);
(b) bookBind = Color.green;
(c) bookBind.setForeground(Color.green);
(d) Button bookBind = new Button("Color.green");
C

(58) Which of the following will cause the entire applet to have a magenta background?
(a) myLabel.setBackground(Color.magenta);
(b) setBackground(Color.magenta);
(c) button4.setBackground(Color.magenta);
(d) nameText.setBackground(Color.magenta);
B

(59) Which of the following runs the jump method on the Frog object froggie?
(a) jump;
(b) jump.froggie();
(c) froggie.jump();
(d) froggie.jump;
C

(60) If class Button extends class Component, which of the following is true?
(a) Class Button cannot have any properties that are not also in Class Component.
(b) Class Button cannot have any methods that are not also in Class Component.
(c) Any method that works for a Component object (like object.move) also works for a Button object.
(d) Any method that works for a Button object (like object.move) also works for a Component object.
C

(61) If class Button extends class Component, what is the relationship between Button and Component?
(a) Button is the class. Component is the sub-class.
(b) Button is the super-class. Component is the sub-class.
(c) Component is the class. Button is the super-class.
(d) Component is the super-class. Button is the sub-class.
D

(62)
for (x=3; x<12; x=x+1)
{
g.drawString("x = "+x,25,25+15*x);
}
For what values of x will drawString put a string on the applet?
(a) 3, 5, 7, 9, 11
(b) 3, 4, 5, 6, 7, 8, 9, 10, 11
(c) 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
(d) 4, 5, 6, 7, 8, 9, 10, 11
B

(63)
for (x=1; x<40; x=x+y)
{
y=x+2;
g.drawString("x = "+x,25,25+15*x);
}
For what values of x will drawString put a string on the applet?
(a) 4, 10, 22
(b) 1, 4, 10, 22, 46
(c) 1, 4, 10, 22
(d) 1, 3, 5, 7, 9, 11, 13, 15, 19, 21, 23, 25, 27, 29, 31, 33, 35, 39
C

(64) Which of the following statements is equivalent to
roomNumber++;
(a) roomNumber+;
(b) roomNumber--;
(c) roomNumber = roomNumber + 1;
(d) roomNumber = roomNumber;<
C

(65) If a while loop is a "pretest" loop, what is a do...while loop?
(a) switch statement
(b) "for" loop
(c) "posttest" loop
(d) "pretest" loop
C

Questions (66)-(69) below all refer to the following:
Button moe = new Button("Alexander");
Button curly = new Button("Graham");
Button larry = new Button("Bell");
Label abc = new Label("American Broadcasting Company");
Label npr = new Label("National Public Radio");

(66) Suppose that the applet contains no setLayout method call, and the add statements are in this order:
add(npr);
add(curly);
add(moe);
add(larry);
add(abc);
In what order will the objects appear in the applet?
(a) "National Public Radio" label, "Graham" button, "Alexander" button, "Bell" button, "American Broadcasting Company" label
(b) "Alexander" button, "Graham" button, "Bell" button, "American Broadcasting Company" label, "National Public Radio" label
(c) "American Broadcasting Company" label, "National Public Radio" label, "Alexander" button, "Graham" button, "Bell" button
(d) "National Public Radio" label, "Alexander" button, "Graham" button, "Bell" button, "American Broadcasting Company" label
A

(67) Suppose that the applet contains:
setLayout(new BorderLayout());
add("North", abc);
add("South", npr);
add("West", moe);
add("Eest", curly);
What appears at the bottom of the applet?
(a) "American Broadcasting Company" label
(b) "National Public Radio" label
(c) "Alexander" button
(d) all three buttons
B

(68) Suppose that the applet contains:
setLayout(new GridLayout(2,2));
add(abc);
add(npr);
add(moe);
add(curly);
What appears in the lower left hand corner of the applet?
(a) "American Broadcasting Company" label
(b) "National Public Radio" label
(c) "Alexander" button
(d) "Graham" button
C

(69) In the
public boolean action (Event e, Object o)
method to monitor events, which statement detects the pushing of the "Bell" button?
(a) if (e.target==larry)
(b) if (e.target=="Bell")
(c) if (e.target==bell)
(d) if (e.target==button)
A

(70) If you have a Cows.class file in a java folder beneath your www folder, what does the APPLET tag look like?
(a) <APPLET CODE="java/Cows" ...>
(b) <APPLET CODEBASE="java" CODE="Cows" ...>
(c) <APPLET CODEBASE="java/Cows" ...>
(d) <APPLET CODE="java/Cows.class" ...>
B

(71) What is a way to reload a page that contains a Java applet that will usually reload the applet as well?
(a) Hold down the Shift key while pushing the Reload button.
(b) Simply push the Reload button.
(c) Push the Back key and then the Forward key to return to the present page.
(d) Hold down the Shift key while pushing the Home button.
A

(72) What is the typical use of Panels?
(a) to use in place of applets
(b) to avoid use of the add method
(c) to ensure that only FlowLayout can be used
(d) to position objects where you want them in applets
D

Questions (73)-(75) below all refer to the following:
Panel upper=new Panel();
Panel lower=new Panel();
upper.setLayout(new GridLayout(2,2));
lower.setLayout(new FlowLayout());

(73) Which of the following will add a button named presshere to the upper Panel?
(a) add(presshere);
(b) Panel.add(presshere);
(c) upper.add(presshere);
(d) upper(presshere);
C

(74) Which of the following will put the lower Panel in the applet?
(a) add(lower);
(b) lower.add();
(c) lower.add(presshere);
(d) lower.add(lower);
A

(75) Which of the following will set the layout for the whole applet to ensure that upper is on top and lower is on bottom?
(a) setLayout(new GridLayout(2,1));
(b) setLayout(new FlowLayout());
(c) upper.setLayout(new GridLayout(2,2));
(d) lower.setLayout(new FlowLayout());
A