Practice midterm-2

Description

Computer Science Quiz on Practice midterm-2, created by Jimit Thakkar on 01/12/2017.
Jimit Thakkar
Quiz by Jimit Thakkar, updated more than 1 year ago
Jimit Thakkar
Created by Jimit Thakkar almost 7 years ago
368
1

Resource summary

Question 1

Question
if you wanted a CSS rule to have all paragraphs of class silly to be centered on the page, which CSS rule would you use?
Answer
  • silly { text-align: center; }
  • p.silly { align: center; }
  • p
  • p.silly { text-align: center; }
  • p < silly { align: center; }

Question 2

Question
In CSS the selector .par matches
Answer
  • all elements whose class is par
  • all elements whose id is par
  • all <p> elements whose id is par
  • all <p> elements whose class is par
  • all<p>elements

Question 3

Question
In PHP, what is the output of the following code $a = 2; $a = $a + 2; $a++; print $a;
Answer
  • 8
  • 2
  • 5
  • 6
  • 4

Question 4

Question
In CSS which property is used to control the size of the text?
Answer
  • font
  • text-style
  • font-style
  • text-size
  • font-size

Question 5

Question
In CSS a rule has the syntax a { b : c ; }. In this rule the symbol a is known as a
Answer
  • value
  • parameter
  • Selector
  • property
  • comment

Question 6

Question
$a = 10; $b = 5; print '$a*$b';
Answer
  • 10*5
  • 50
  • you will get an error
  • $a*$b

Question 7

Question
Which of the following is a valid CSS selector ?
Answer
  • p { color red }
  • p color red
  • p { color: red; }
  • p color: red;
  • p.color { red; }

Question 8

Question
In PHP, what would be the output of the following code: $a = 10; $b = 10; print "$a * $b";
Answer
  • you will get an error
  • 100
  • $a * $b
  • 10*10

Question 9

Question
Where should the reference to a style sheet be placed in an HTML document ?
Answer
  • In the <head> section.
  • In the <style> section.
  • In the 'tail> section.
  • In the <body> section.
  • In the <css> section.

Question 10

Question
What is the order of priority (from highest to lowest) that styles are applied to an element?
Answer
  • inline style, embedded style, externally linked style, default html style style sheet, the browser default
  • default html style, embedded style, inline style, externally linked style Incorrect
  • embedded style, inline style, externally linked style, default html style
  • externally linked style, embedded style, inline style, default html style
  • externally linked style, default html style, embedded style, inline style

Question 11

Question
In CSS, considering the CSS Box Model, would be the final width of an element with the following id? #item { width: 100px; border: 5px; margin: 5px; padding: 0px; }
Answer
  • 100
  • 110
  • 105
  • 120
  • 90

Question 12

Question
In CSS the selector p matches
Answer
  • all <p> elements whose class is p
  • all elements whose id is p
  • all <p> elements whose id is p
  • all elements whose class is p
  • all <p> elements

Question 13

Question
The following PHP code has an error. What line is this error on? 0: $a = 10 + 1; 1: $b = "10" 2: if ($a <> $b) 3: { 4: print "Not equal"; 5: } 6: else 7: { 8: $b++; 9: }
Answer
  • 0
  • 1
  • 4
  • 2

Question 14

Question
Considering the CSS box model, what is the final width of an element of this class: .item { width: 100px; margin: 10px; padding-left: 10px; padding-right: 0px; }
Answer
  • 120
  • 130
  • 150
  • 100

Question 15

Question
Which of the following would change the background colour for all <h1> elements to white?
Answer
  • h1.all { background-color: white }
  • header1 { background-color: white }
  • .h1 { background-color: white }
  • h1 { background-color: white }

Question 16

Question
In CSS which property is used to control the background color?
Answer
  • color
  • backgroung-color
  • background-colour
  • bgcolor

Question 17

Question
In CSS to apply color: red to h1 and h2 you could use the rule(s)
Answer
  • h1.h2 { color : red; }
  • h1:h2 { color : red; }
  • h1, h2 { color : red; }
  • h1 { color : red; } h2 { color : blue; }
  • h1 { red : color; } h2 { red : color; }

Question 18

Question
In CSS which property is used to control the text color of an element?
Answer
  • text-color
  • background-color
  • foreground-color
  • text-colour
  • color

Question 19

Question
The difference between serif and sans-serif fonts is that
Answer
  • serif fonts have small lines at the end of some characters while sans-serif do not
  • sans-serif fonts have small lines at the end of some characters while serif do not
  • sans-serif fonts are monospaced while serif have variable width
  • serif fonts are monospaced while sans-serif have variable width
  • sans-serif fonts can be used without paying a royalty, while a royalty must be paid for serif fonts

Question 20

Question
Which of the following is not a valid variable in PHP?
Answer
  • $1name
  • $name
  • $_name1
  • $name1
  • $Name

Question 21

Question
In PHP what is the value of $a $s = "Hello World"; $a = $s[7];
Answer
  • "o"
  • you will get an error
  • "Hello"
  • "W"
  • 7

Question 22

Question
In PHP, what will be the output of the following code $a = "hello "; $b = "world "; $c = 10; print $a . $c . $b ;
Answer
  • you will get an error
  • hello 10 world
  • 10
  • hello world
  • hello

Question 23

Question
[HTML] In PHP, what is the output of the following code: $a = 10; $b = "10"; if ($a == $b) { print "hello "; } print "world";
Answer
  • hello
  • world
  • $a
  • $b
  • hello world

Question 24

Question
In CSS the selector #p matches
Answer
  • all <p> elements
  • all elements whose class is p
  • all elements whose id is p
  • all <p> elements whose id is p
  • all <p> elements whose class is p

Question 25

Question
The background of a given HTML element can be manipulated with
Answer
  • you cannot change the background of an element
  • only background-image
  • background-color, background-image
  • only background-color

Question 26

Question
In CSS which property is used to control the horizontal alignment of text in an element?
Answer
  • text-align
  • alignment
  • center-align
  • center
  • align

Question 27

Question
$a = 2 + 3 * 5 + 10; print $a;
Answer
  • 27
  • 23510
  • 35
  • 20

Question 28

Question
It is possible to define CSS in
Answer
  • only inline
  • only in external style sheets and internal style sheets
  • only in external style sheets
  • only in internal style sheets
  • external style sheets, internal style sheets, and inline

Question 29

Question
Which of the following is the correct HTML to refer to an external style sheet style.css ?
Answer
  • <style "style.css\">
  • <link rel="stylesheet" type="text/css" href="style.css">
  • <style> style.css</style>
  • <css rel="stylesheet" type="text/css" href="style.css">
  • <css> style.css</css>

Question 30

Question
What does CSS stand for?
Answer
  • Cascading Style Sheets
  • Computer Style Sheets
  • CSS does not stand for anything
  • Computer Symbol Sheets
  • Cascading Symbols and Symptoms

Question 31

Question
In PHP what is the data type of the variable $c? $a = "10"; $b = "20"; $c = $a * $b;
Answer
  • array
  • float
  • string
  • boolean
  • integer

Question 32

Question
CSS enables links to be styled differently depending on what state they are in. To set the hover colour for a link to be white, one would code a CSS rule
Answer
  • a { color : white ; hover : true ;}
  • a:link { color : white ; }
  • a { color : white ; hover-dwell : true ;}
  • a { hover-color : white ;}
  • a:hover { color : white ; }

Question 33

Question
In CSS, which property would be used to allow an image to be positioned on the right?
Answer
  • clear: right
  • float: right
  • align: righ
  • overflow: hidden

Question 34

Question
In CSS, what is the range for the R, G, B when specifying a color using rgb(R, G, B) ?
Answer
  • 1-256
  • 0xFFFFFF
  • 0-255
  • 1-100
  • 0-1

Question 35

Question
In PHP what is the data type of the variable $c? $a = 10; $b = 1.238; $c = $a * $b;
Answer
  • String
  • array
  • float
  • integer
  • boolean

Question 36

Question
In CSS a rule has the syntax a { b : c ; }. In this rule the symbol a is known as a
Answer
  • parameter
  • Selector
  • value
  • comment
  • property

Question 37

Question
In PHP, what would be the output of the following code: $a = 10; $b = 10; print "$a * $b";
Answer
  • 100
  • 10*10
  • $a*$b
  • you will get an error

Question 38

Question
In CSS the selector p matches
Answer
  • all <p> elements
  • all elements whose class is p
  • all elements whose id is p
  • all <p> elements whose id is p
  • all <p> elements whose class is p

Question 39

Question
Which of the following would change the background colour for all <h1> elements to white?
Answer
  • h1.all { background-color: white }
  • h1 { background-color: white }
  • header1 { background-color: white }
  • .h1 { background-color: white }

Question 40

Question
In CSS which property is used to control the background color?
Answer
  • colour
  • background-color
  • color-background
  • bgcolor
  • color

Question 41

Question
Which of the following is a valid CSS selector ?
Answer
  • p.color { red; }
  • p color: red;
  • p color red
  • p { color: red; }
  • p { color red }

Question 42

Question
Which of the following will cause you to open the link in a new tab or browser window?
Answer
  • <a href="http:www.cse.yorku.ca" target="_blank">
  • <a href="http:www.cse.yorku.ca" target="_top">
  • <a href="http:www.cse.yorku.ca" target="_new">
  • <a href="http:www.cse.yorku.ca" target="new">
  • <a href="http:www.cse.yorku.ca" target="/">

Question 43

Question
Which of the following HTML elements defines the title of a document?
Answer
  • <title text="This is a title">
  • <head>This is a title</head>
  • <title>This is a title</title>
  • <meta>This is a title</meta>
  • <html>This is a title</html>

Question 44

Question
How could you output the following text in HTML?: <p> This is an example of a paragraph tag </p> in HTML
Answer
  • <p> <<p>> his is an example of a paragraph tag <<\p>> in HTML </p>
  • <p> "<p> This is an example of a paragraph tag </p> in HTML" </p>
  • <p> \<p\> his is an example of a paragraph tag \</p\>" in HTML </p>
  • <p> &lt;p&gt; This is an example of an paragraph tag &lt;/p&gt; in HTML </p>

Question 45

Question
Which of the following HTML tags are classified as empty or void tags? Choose the most complete answer
Answer
  • <hr>
  • No HTML tags are allowed to be empty or void. Incorrect
  • <hr>, <br> and <img>
  • <br> and <p>
  • <hr>, <br> and <p>

Question 46

Question
The syntax of HTML requires that the name and value of an element's attribute be separated by:
Answer
  • an equal sign.
  • a semicolon.
  • a tab.
  • one or more spaces.
  • a comma.

Question 47

Question
Every HTML element has a parent element except:
Answer
  • <meta>
  • <br/>
  • <head>
  • <html>
  • <body>

Question 48

Question
Which of the following correctly creates a hyperlink?
Answer
  • <a href="http:www.yorku.ca">EECS</a>
  • <a name="http:www.yorku.ca">EECS</a>
  • <a url="http:www.yorku.ca">EECS</a>
  • <a "http:www.yorku.ca">EECS</a>
  • <a link="http:www.yorku.ca">EECS</a>

Question 49

Question
The tag <!-- DOCTYPE html --> is interpreted by your browser as ....
Answer
  • this is a comment, the browser ignores it.
  • this page is written using a word processor.
  • this page is written using HTML syntax.
  • this page was intentionally left blank.
  • this page has an associated CSS.

Question 50

Question
How would you insert a copyright symbol into a web page?
Answer
  • <copyright>
  • <copyright />
  • <symbol tag="copyright" />
  • <sym tag="copyright" />
  • &copy;

Question 51

Question
Which tag is not associated with tables in HTML?
Answer
  • <row>
  • <td>
  • <tr>
  • <table>
  • <th>
  • <caption>

Question 52

Question
Which of the following characters is used to indicate the end of a tag?
Answer
  • ^
  • *
  • >
  • <
  • #

Question 53

Question
The 'C' in W3C stands for:
Answer
  • Consortium
  • Corporation
  • Committee
  • Control
  • Central

Question 54

Question
It is important that your web pages follow web standards so that
Answer
  • they will render properly over a range of different browsers and devices.
  • they will be approved by Google.
  • they will be more efficient to compress and transfer across the web.

Question 55

Question
meta tags in the header section of a web page
Answer
  • supports caching that otherwise would not be possible
  • enable the browser to render your page more efficiently.
  • enable the server to transmit your page more efficiently.
  • provide valuable information to search engines and browsers about the structure and content of your document.
  • support global name search and replace.

Question 56

Question
The WWW is attributed to which person?
Answer
  • Bill Gates
  • Tim Cerf
  • Vincent Cerf
  • Tim Berners-Lee

Question 57

Question
Which protocol provides multiplex?
Answer
  • Transmission Control Protocol
  • Hypertext Transport Protocol
  • Data Layer Protocol
  • Internet Protocol

Question 58

Question
Which of the following characters is used to indicate the start of a tag?
Answer
  • <
  • >
  • *
  • #
  • ^

Question 59

Question
The syntax template for a basic html page will ...
Answer
  • Use <head> ... </head> tags to identify the author of the page.
  • Surround the page with <html> ... </html> tags.
  • Properly indent material within the page so that it is readable.
  • Surround the page with <head> ... </head> tags.
  • Begin with <html> and end with </body>

Question 60

Question
Which group is in charge of deciding top-level domain names?
Answer
  • W3C
  • ICANN
  • IETF
  • Google

Question 61

Question
Which is not a valid URL format?
Answer
  • http://yorku.ca
  • http://130.63.236.137/index.html
  • http://yorku.ca:80
  • http://www.textpad.com/download/index.html
  • 1Wh8RzcQZr4
  • http://www.youtube.com/watch?v

Question 62

Question
HTML is intended to ...
Answer
  • provide an efficient representation to download material from the web.
  • provide neither appearance nor structure to a document.
  • provide both appearance and structure to a document.
  • provide the appearance of a document but not specify its structure.
  • provide structure and content to a document but not specify its appearance.

Question 63

Question
Text that is be emphasized should be surrounded with
Answer
  • <emphasize> and </emphasize>
  • <em> and </em>
  • <i> and </i>
  • <b> and </b>
  • <font size="large"> and </font>

Question 64

Question
Which of the following tags starts a numbered list?
Answer
  • <list type="numbered">
  • <list>
  • <ol>
  • <ul>
  • <numbered>

Question 65

Question
In HTML comments start with ... and end with ...
Answer
  • they start with <comment> and end with </comment>
  • they start with /** and end with **/
  • they start with <!-- and end with -->
  • they start with // and end with a carriage return
  • they start with /* and end with */

Question 66

Question
In HTML, paragraphs start with ... and end with ....
Answer
  • start with <center> and end with </p>
  • start with <p> and end with <li>
  • start with <br> and end with </br>
  • start with <p> and end with </p>
  • start with <p> and end with <ol>

Question 67

Question
In HTML the following heading tags are permitted
Answer
  • <head>
  • <h1> through <h6>
  • <h1> through <h9>
  • <heading>, <subheading>, <subsubheading>
  • <heading>, <subhead>, <subsubhead>

Question 68

Question
Which of the following is correct HTML5 for displaying an image?
Answer
  • <img file="image gif" alt="an image">
  • <img src="image.gif" alt="an image">
  • <img src="image.gif">
  • <image src="image.gif" alt="an image">
  • <image alt="image.gif">

Question 69

Question
Are the Internet and WWW the same thing?
Answer
  • No
  • Yes

Question 70

Question
If some text is preceded by <p><em> then it must be proceeded by:
Answer
  • </p em>
  • </p></em>
  • </em></p>
  • </em /p>
  • any of the above.

Question 71

Question
Which is not a valid IP address format?
Answer
  • 200.43.33.34
  • 128.0.44.1
  • 56.0.267.34
  • 1.21.44.129

Question 72

Question
Which of the following tags starts a bulleted list?
Answer
  • <bulleted>
  • <ol>
  • <list>
  • <ul>
  • <list type="bulleted">

Question 73

Question
Which of the following tags creates a definition list?
Answer
  • <dl>
  • <nl>
  • <ol>
  • <ul>
  • <li>

Question 74

Question
Which HTML element will not ignore spaces in text content
Answer
  • <h1>
  • <a>
  • <code>
  • 'p"
  • <pre>

Question 75

Question
Tags that are not directly displayed on the page are written in the _____ section.
Answer
  • <title>
  • <head>
  • <html>
  • <p>
  • <body>

Question 76

Question
Which of the following is true about block and inline elements in HTML?
Answer
  • Block elements represent blocks of text. All other entries are in-line elements.
  • Block elements generally represent a relatively large portion of a page and may contain other tags within it. Inline elements generally represent smaller portions of a page and are contained within a block element.
  • Block elements generally represent a relatively large poriton of a page, but cannot contain other elements wihtin them. Inline elements generally represent smaller portions of a page and are contained within nesting elements.
  • Block elements are the building blocks of html documents and must be contained within inline elements.
  • Block elements, nested elements, and inline elements must all be contained within meta elements.

Question 77

Question
What is the correct HTML element for inserting a line break?
Answer
  • <h1>
  • <br>
  • <p>
  • <paragraph>
  • <break>

Question 78

Question
Which of the following is not an HTML element?
Answer
  • DOCTYPE
  • html
  • img
  • table
  • body

Question 79

Question
Which server is used to help determine the IP address of yorku.ca
Answer
  • Apache Web Server
  • Domain Name Server
  • Microsoft Internet Information Server (IIS)
  • Google Server

Question 80

Question
meta tags in the header section of a web page
Answer
  • support global name search and replace.
  • enable the server to transmit your page more efficiently
  • provide valuable information to search engines and browsers about the structure and content of your document
  • supports caching that otherwise would not be possible.
  • enable the browser to render your page more efficiently.

Question 81

Question
The WWW is attributed to which person?
Answer
  • Bill Gates
  • Tim Cerf
  • Tim Berners-Lee
  • Vincent Cerf

Question 82

Question
In PHP, what is the output of the following code? $a = "a|b|c|d|e|f|g"; $c = explode("|", $a); print $c[1];
Answer
  • b
  • a
  • |
  • d
  • a|b|c|d|e|f|g

Question 83

Question
In PHP file I/O what does the function file_get_contents() do?
Answer
  • returns a single string with the entire contents of the file
  • returns an array of strings where each string is a line in the file
  • writes data to a file
  • checks to see if a file exists

Question 84

Question
In HTML forms, input type="____" is a submit button?
Answer
  • submitbutton
  • submit
  • text
  • value="submit"

Question 85

Question
In PHP, what would be the output of the following? $nickname = array("Robert" => "Bob", "Michael" => "Mike", "Abdelraham" => "Abdo", "Yaoling" => "Yaoyoa"); print $nickname["Robert"];
Answer
  • Abdo
  • Mike
  • Yaoyao
  • Bob

Question 86

Question
In PHP file I/O, file() does what?
Answer
  • returns an array of strings where each string is a line in the file
  • writes data to a file
  • returns a single string with the entire contents of the file
  • checks to see if a file exists

Question 87

Question
In HTML forms, what is the CSS selector for an input type="text"?
Answer
  • .input text
  • input .text
  • input[type="text"]
  • input["type=text"]
  • ["type=text"]

Question 88

Question
In PHP, what would be the value of the variable $c? $a = array("red", "green", "blue", "yellow"); $c = count($a);
Answer
  • 3
  • yellow
  • 5
  • 4

Question 89

Question
In PHP, what is the output of the following code? $a = array("Abdel", "Didi", "Justin", "Trump"); if (in_array("Ford", $a)) { print "found"; } else { print "not found"; }
Answer
  • found
  • no output
  • this will cause an error
  • not found

Question 90

Question
Which line of the following PHP code has an error? 0: $c = rand(1,10); 1: if ( c == 5 ) 2: { 3: print " $color "; 4: }
Answer
  • 2
  • 0
  • 4
  • 1
  • 3

Question 91

Question
What variable in PHP is used to access data passed via the post method in HTML forms?
Answer
  • $_POST
  • $POST
  • $_DATA
  • $GET
  • $_GET

Question 92

Question
What are the results of the following boolean expressions? 1) 5 < 4 2) 10 > 5 3) 5 == 20
Answer
  • 1) true , 2) true, 3) true
  • 1) true, 2) false, 3) false
  • 1) false, 2) false, 3) false
  • 1) false, 2) true, 3) false

Question 93

Question
In HTML forms, input type="____" is a radio button?
Answer
  • radio button
  • radio
  • check
  • rad
  • radiobutton

Question 94

Question
Which file I/O function writes a data to a file in PHP?
Answer
  • file()
  • file_get_contents()
  • file_put_contents()
  • printfile()
  • file_write_contents()

Question 95

Question
In PHP, what is the value of the variable $c? $a = array("red", "green", "yellow"); $b = "hello"; $c = $b . " " . strtoupper($a[1]);
Answer
  • hello RED
  • HELLO GREEN
  • hello GREEN
  • hello RED GREEN YELLOW
  • HELLO RED

Question 96

Question
What variable in PHP is used to access data passed via the URL?
Answer
  • $_GET
  • $GET
  • $_POST
  • $POST
  • $_DATA

Question 97

Question
In HTML forms, the HTML element label does what?
Answer
  • specifics the URL for the data to be sent to
  • associates text with an UI input
  • creates a label icon
  • creates a text input
  • creates a box around some UI

Question 98

Question
Using HTML forms, the tag <form method="___"> transmits data from the form using the URL?
Answer
  • put
  • post
  • get
  • url

Question 99

Question
In HTML forms, which UI tag does not require a close tag?
Answer
  • <form>
  • <input>
  • <textarea>
  • <select>

Question 100

Question
In PHP, what would be the output of the following? $a = "hello world"; print $a[0];
Answer
  • l
  • you will get an error
  • h
  • hello

Question 101

Question
What is the output of the following PHP code? $a = "string"; $a = strtoupper($a); print $a[4];
Answer
  • STRING
  • I
  • i
  • N
  • n

Question 102

Question
In PHP, $a[] = "hello" does what?
Answer
  • this will cause a syntax error in PHP
  • appends the string "hello" to the end of the array
  • sets all array elements to "hello"
  • puts the string "hello" at the beginning of the array

Question 103

Question
In JavaScript, which of the following is not a valid comparison operator?
Answer
  • ===
  • !=
  • >=
  • =!=
  • ==
  • !==

Question 104

Question
Consider the following JavaScript code snippet var q = 1 + 2 + parseInt("3"); After this executes, what value does q have?
Answer
  • 33
  • 6
  • 123
  • "123"

Question 105

Question
In JavaScript, after executing var x = "hello"; then if you wanted to have var z have the value of the number of characters in x, you could use
Answer
  • var z = x.length();
  • var z = length(x);
  • var z = x.length;
  • var z = 3;
  • var z = x.len;

Question 106

Question
In JavaScript, after executing var x= "hello"; then if you wanted to have var z contain a string of the last character in x, you could use
Answer
  • var z = x.charAt(4);
  • var z = 'h';
  • var z = x.charAt(3);
  • var z = x.charAt(-1);
  • var z = "h";

Question 107

Question
Which variables below a global variable? var i=0; function foo() { var a = 10; var b = 20; var c = a*10 + b; }
Answer
  • b
  • a
  • i
  • c

Question 108

Question
In JavaScript single line comments start with
Answer
  • //
  • /
  • ##
  • #
  • C

Question 109

Question
In JavaScript, after executing var x = 2; var z = 1; if (x == 4) { z = 6; } else { z = 3; } then z has the value
Answer
  • 3
  • infinity
  • 4
  • 1
  • 6

Question 110

Question
In JavaScript, after executing var x = 4; var z = 1; if (x > 0) { z = 2; } then z has the value
Answer
  • 4
  • 0
  • 1
  • 2

Question 111

Question
In JavaScript, how many times does the code for(var x=0;x<5;x++) alert("hi"); cause an alert box to appear on the screen?
Answer
  • 5
  • 3
  • 4
  • 1
  • 2

Question 112

Question
What global event is called once the HTML page has loaded?
Answer
  • HTML.pageLoad
  • window.onload
  • document.pageLoaded
  • window.load
  • document.onload

Question 113

Question
In JavaScript, which of the following is interpreted as being false in a logical expression
Answer
  • NaN
  • 123
  • 3.1415
  • true
  • "hello world"

Question 114

Question
In JavaScript multiple line comments are surround with
Answer
  • // and //
  • /* and *
  • ## and ##
  • // and */
  • /* and //

Question 115

Question
Consider the following HTML code: <div id="myDiv"> <p id="myP"> This is a test.</p> </div> How do you access the paragraph element above in JavaScript?
Answer
  • var a='<p id="myP">';
  • var a=document.getElementById("myP");
  • var a=document.getElementById("p);
  • var a=document.getElementById("myDiv);

Question 116

Question
In JavaScript, after executing var x = "2"; var y = "2"; var z = x + y; then the value of z is
Answer
  • 22
  • "22"
  • this is invalid and will cause a run time error
  • 4

Question 117

Question
In JavaScript, after executing var x = 10; var z = "" + x; then the value of z is
Answer
  • "1","0"
  • 10
  • "10"
  • ""
  • this is invalid and will cause a run time error

Question 118

Question
What does DOM stand for?
Answer
  • Direct Object Manipulation
  • Document Object Model
  • Document Object Module
  • Detailed Object Map

Question 119

Question
Which of the following is not a fundamental type in JavaScript?
Answer
  • Number
  • Module
  • String
  • Boolean
  • Array

Question 120

Question
What is the proper way to define an array in JS?
Answer
  • var a =["a", "b", "c", "d"];
  • var a =("a", "b", "c", "d");
  • var a ="a", "b", "c", "d";
  • var a =array("a", "b", "c", "d");

Question 121

Question
How would you create an alert box with "Hello" in JavaScript?
Answer
  • print("Hello")
  • alert("Hello")
  • log("Hello")
  • msgBox("Hello")
  • dialog("Hello")

Question 122

Question
The following code is considered? <button id="ok" onclick="okayClick();">OK</button>
Answer
  • obtrusive JavaScript
  • unobtrusive JavaScript

Question 123

Question
Consider the following JavaScript code. What type is the variable p? var p = document.getElementsByTagName("p");
Answer
  • an array of element objects
  • a DOM tree
  • a paragraph
  • an element object

Question 124

Question
What does the following JavaScript code do? var myP = document.getElementById("myP"); myP.children[1].style.backgroundColor = "silver";
Answer
  • Sets the background color to silver of the third child of element id="myP"
  • Modifies all children of elemetn id="myP"
  • Sets the background color to silver of the first child of element id="myP"
  • Sets the element id="myP" background to silver
  • Sets the second child of element id="myP" background to silver

Question 125

Question
Based on the following JS code which variable is local scoped? var a=10; function myFunc() { var c=document.getElementById("myPar"); }
Answer
  • a
  • document
  • both a and c
  • c

Question 126

Question
What does the following JavaScript code snippet do? $("button").stopObserving("mousemove");
Answer
  • removes the event handler function named "mousemove"
  • stops the mouse from moving over any buttons
  • removes the event handler function named "mousemove" for element with id="button"
  • removes the event handler function for "mousemove" events for element with id="button"

Question 127

Question
In the Prototype library, the $("p") function is equivalent to?
Answer
  • document.getElementsByTagName("p");
  • document.createElement("p");
  • document.getElementByTagName("p");
  • document.getElementById("p");

Question 128

Question
When does the global event "window.onload" get called?
Answer
  • As soon as the JS file is linked to the HTML page.
  • When a new window is created by an alert().
  • Only when the browser's refresh button is pressed.
  • After the webpage has been loaded.

Question 129

Question
Consider the following JavaScript code: 0: var allParas = document.getElementsByTagName("p"); 1: for (var i = 0; i < allParas.length; i++) { 2: ??? 3: } What code should be placed on line 2 to make the background color of all p elements silver?
Answer
  • allParas[i].style.backgroundColor = "silver";
  • allParas[i].backgroundColor = "silver";
  • allParas.style.backgroundColor = "silver";
  • allParas.backgroundColor = "silver";

Question 130

Question
Are the following two lines of code equivalent? $("button").observe("click", myClick); $("button").onclick = myClick;
Answer
  • No
  • Yes

Question 131

Question
In Javascript, if you wanted to set a timer that calls function "myFunc" every second, which statement would you use?
Answer
  • setTimeout(myFunc, 1000);
  • setInterval(myFunc, 1000);
  • setInterval(1000, myFunc);
  • setTimeout(myFunc, 1000, REPEAT);
  • setRepeat(myFunc, 1000);

Question 132

Question
Consider the following HTML form object: <input type="text" id="name"> How do you access content the user typed into this text field?
Answer
  • $("name").data
  • $("name").innerHTML
  • $("name").submit()
  • $("name").value

Question 133

Question
Assume function myClick is already defined. Which line in the following JavaScript code contains an error? 0: var allPars = document.getElementsByTagName("p"); 1: var myButton = document.getElementById("myButton"); 2: myButton.onclick = myClick; 3: allPars.onclick = myClick;
Answer
  • 3
  • 0
  • 2
  • 1
  • There is no error in this code.

Question 134

Question
Consider the following HTML code as a DOM tree: <div id="myDiv"> <h1> Hello </h1> <p> This is a test. </p> <p> This is only <a href=""> a test. </a> </p> <p> There will be one more test. </p> </div> Is the h1 element an ancestor of the element <a>?
Answer
  • No
  • Yes

Question 135

Question
Consider the following HTML: 0: <div> 1: <h1> A </h1> 2: <p> B </p> 3: <p> C </p> 4: </div> which statement would return the element at line 3?
Answer
  • $("p")
  • getElementById("p")
  • $("h1").children[0]
  • $("div").children[2]

Question 136

Question
Using the Prototype library, which of the following would be used to submit a form?
Answer
  • $("myForm").submitForm();
  • document.submit();
  • $("myForm").submit();
  • $("myForm").submit = true;

Question 137

Question
Consider the following HTML code as a DOM tree: <div id="myDiv> <h1> Hello </h1> <p> This is a test. </p> <p> This is only <a myid="a" href=""> a test. </a> </p> <p> There will be one more test. </p> </div> Is the element myid="a" a child of the div element?
Answer
  • no
  • yes

Question 138

Question
Consider the following HTML code as a DOM tree: <div id="myDiv> <h1> Hello </h1> <p> This is a test. </p> <p> This is only <a href=""> a test. </a> </p> <p> There will be one more test. </p> </div> How many descendant element nodes does the div have?
Answer
  • 5
  • 0
  • 3
  • 4

Question 139

Question
What does the variable "this" refer to in the following JavaScript function: function clickHandler() { this.innerHTML = "clicked"; }
Answer
  • it refers to an HTML button element.
  • it refers to document.getElementsByTag("this").
  • it refers to an HTML checkbox element.
  • it refers to the HTML element object that called this function.

Question 140

Question
In JavaScript, does the DOM tree include the head section of the HTML page?
Answer
  • no
  • yes

Question 141

Question
Consider the following HTML and JS code. What is the value of pars.length? <body> <p> Paragraph 1 </p> <div id="myDiv"> <p> Paragraph 2 </p> </div> </body> var myDiv=document.getElementById("myDiv"); var pars=document.getElementsByTagName("p");
Answer
  • 2
  • 3
  • 1
  • 0

Question 142

Question
How would you create a new DOM node of type <p> in JavaScript?
Answer
  • document.createElement("p");
  • $("p").create();
  • document.newParagraph(1);
  • document.createTextNode("<p>");
  • document.getElementById("p");

Question 143

Question
In JavaScript, does the DOM tree include the head section of the HTML page?
Answer
  • no
  • yes

Question 144

Question
Consider the following JavaScript code. When will the function "myFunc" be called? window.onload = function() { setTimeout(myFunc, 1500); }
Answer
  • After 1.5 seconds after the window.onload event
  • After 3pm on the current day the webpage is being accessed.
  • After 1500 seconds after the window.onload event
  • After 15 seconds after the window.onload event

Question 145

Question
What does the following JavaScript code snippet do? $("button").stopObserving("mousemove");
Answer
  • stops the mouse from moving over any buttons
  • removes the event handler function named "mousemove"
  • removes the event handler function for "mousemove" events for element with id="button"
  • removes the event handler function named "mousemove" for element with id="button"

Question 146

Question
When does the global event "window.onload" get called?
Answer
  • After the webpage has been loaded.
  • Only when the browser's refresh button is pressed.
  • When a new window is created by an alert().
  • As soon as the JS file is linked to the HTML page.

Question 147

Question
In JavaScript, which of the following provides the X coordinates with respect to the HTML element the mouse is over?
Answer
  • event.browserX
  • event.offsetX
  • event.clientX
  • event.screenX

Question 148

Question
When interpreted as a DOM tree, how child nodes does div id="myDiv" have has children? <p> Paragraph 1 </p> <div id="myDiv"> <ul> <li> Item 1 </li> <li> Item 2 </li> <li> Item 3 </li> </ul> </div> <p> Paragraph 2 </p>
Answer
  • 3
  • 1
  • <ul>
  • 4

Question 149

Question
Consider the following JS Prototype code. When will the function "myFunc" be called? $("myPar").observe("mouseover", myFunc); $("myPar").observe("keydown", myVar)
Answer
  • anytime an event occurs with element id="myPar"
  • when the mouse cursor enters element id="myPar"
  • anytime the mouse cursor moves within the element id="myPar"
  • when a key is pressed down over element id="myPar"

Question 150

Question
In JavaScript, what command can be used to remove a node from the DOM tree?
Answer
  • document.removeChild(...)
  • document.killChild(...)
  • document.unappendChild(...)
  • document.deleteChild(...)

Question 151

Question
Consider the following HTML code as a DOM tree. How many children does the <body> element have? <body> <h1> My webpage </h1> <div> <p> Testing. </p> <p> Another paragraph. </p> </div> </body>
Answer
  • 2
  • 0
  • 1
  • 4
Show full summary Hide full summary

Similar

Computing Hardware - CPU and Memory
ollietablet123
SFDC App Builder 2
Parker Webb-Mitchell
Intake7 BIM L1
Stanley Chia
Data Types
Jacob Sedore
Software Processes
Nurul Aiman Abdu
Design Patterns
Erica Solum
CCNA Answers – CCNA Exam
Abdul Demir
Abstraction
Shannon Anderson-Rush
Spyware
Sam2
HTTPS explained with Carrier Pigeons
Shannon Anderson-Rush
Data Analytics
anelvr