javascript quizs

22
Q1 Question 1. Question : What is the primary tool a client uses to interact with a web server? Student Answer: Web Browser Instructor Explanation: Points Received: 10 of 10 Comments: Question 2. Question : What are the top 3 web clients seen by web sites (be sure to cite your source, e.g., StatsCounter.com, and your assumptions) Student Answer: Google Chrome Mozilla Firefox Internet Explorer Source: w3schools.com/browsers Points Received: 10 of 10 Comments: No source or assumption s Question 3. Question : JavaScript is run on the: Student Answer: Client Server It must run on both the client and the server No one knows Points Received: 10 of 10 Comments: Question 4. Question : What are the top 2 devices used to access web sites (cite your source and assumptions) ? Student Answer: smart mobile phone and Tablet Source:Tech crunch and splashtop. com Points Received: 10 of 10 Comments: Question 5. Question : What is the name of the protocol used by a client to communicate with with a web server?

Upload: oudy525i2000

Post on 17-Oct-2015

173 views

Category:

Documents


5 download

TRANSCRIPT

Q1

Question1.Question :What is the primary tool a client uses to interact with a web server?

Student Answer:Web Browser

Instructor Explanation:

Points Received:10 of 10

Comments:

Question2.Question :What are the top 3 web clients seen by web sites (be sure to cite your source, e.g., StatsCounter.com, and your assumptions)

Student Answer:Google Chrome Mozilla Firefox Internet Explorer Source: w3schools.com/browsers

Points Received:10 of 10

Comments:No source or assumptions

Question3.Question :JavaScript is run on the:

Student Answer:Client

Server

It must run on both the client and the server

No one knows

Points Received:10 of 10

Comments:

Question4.Question :What are the top 2 devices used to access web sites (cite your source and assumptions)?

Student Answer:smart mobile phone and Tablet Source:Techcrunch and splashtop.com

Points Received:10 of 10

Comments:

Question5.Question :What is the name of the protocol used by a client to communicate with with a web server?

Student Answer:HTTP (Hypertext Transfer Protocol)(A correct answer: http)

Instructor Explanation:

Points Received:10 of 10

Comments:

Question6.Question :A web page with fixed content is called:

Student Answer:static website(A correct answer: static)

Instructor Explanation:

Points Received:10 of 10

Comments:this is really a page, not a site.

Question7.Question :An important view to see errors reported by JavaScript is the:

Student Answer:Javascript Console

Instructor Explanation:

Points Received:10 of 10

Comments:

Question8.Question :What is the value of this statement?NaN === NaN

Student Answer:true

false

It depends on the browser

It is an error

Points Received:10 of 10

Comments:

Question9.Question :Please provide any information that will help in evaluation of your quiz.

Student Answer:Prefer questions that help different techniques to web development.

Points Received:1 of 1

Comments:

* Times are displayed in (GMT-07:00) Mountain Time (US & Canada)

Q2

Question1.Question :JavaScript identifiers are case sensitive

Student Answer:TrueFalse

Points Received:10 of 10

Comments:

Question2.Question :Declare a variable named x initialized to the numeric value zero.

Student Answer:var x = 0;(A correct answer: var x=0;)

Instructor Explanation:

Points Received:10 of 10

Comments:

Question3.Question :Declare a single string variable namedtopinitialized to represent this two-line string:titlefollowed bysubtitleon the second line.

Student Answer:var Top = 'title followed by \n' + 'subtitle on the second line';(A correct answer: var top='title\nsubtitle';)

Instructor Explanation:

Points Received:9 of 10

Comments:

Question4.Question :Which of the following are legal identifiers in JavaScript

Student Answer:us$currency

cloud9

topsy-turvy

23skidoo

one_fine_day

Points Received:10 of 10

Comments:

Question5.Question :Write an assignment to variableaveragethat adds up the 5 numbers 93, 96, 89.5, 79, and 85.5, in that order, and divides the result by 5 using addition and division operators

Student Answer:function sum(myArray) { var total=0; for (var i = 0; i < myArray.length; i+=1) { total += myArray[i]; } return total; } function average(myArray) { var s=sum(myArray), count=myArray.length; return s / count ; } var scores = [93, 96, 89.5, 79, 85.5]; var tot = sum(scores); var avg = average(scores); console.log("// Scores: "+scores+"; Average: "+avg);(A correct answer: var average=(93+96+89.5+79+85.5)/5.)

Instructor Explanation:

Points Received:6 of 10

Comments:No assignment to variable "average". Rather this is ends up as a function which performs that (e.g., average(scores) rather than average, as requested.

Question6.Question :Mark the ones that are true, given these initial assignments:var x=[], y=[];var z = Number("three");var u='3', v=2+1, w=3.0;

Student Answer:x==y

x===y

z==NaN

isNaN(z)

u==v

u===v

v==w

v===w

Points Received:10 of 10

Comments:

Question7.Question :How many times is the followingwhileloop executed:var i=3;while (i < 10) { i += 1;}

Student Answer:10(A correct answer: 7)

Instructor Explanation:

Points Received:4 of 10

Comments:

Question8.Question :What will the following code fragment output?var a=0;if ( true) { var a = 9;}console.log(String(a));

Student Answer:9

Instructor Explanation:In JavaScript, unlike other languages you may have encountered, it is not an error to declare the same variable twice.Nor does an if statement, even with curly braces, create a new scope for variables.

Points Received:10 of 10

Comments:

Question9.Question :What will the following code fragment output?var x='3';var y='4';console.log(x+y);

Student Answer:34

Instructor Explanation:As strings, the "+" is concatenation.

Points Received:10 of 10

Comments:

Question10.Question :What does the window prompt method do when the user clicks Cancel?

Student Answer:nothing happens(A correct answer: returns null)

Instructor Explanation:

Points Received:0 of 10

Comments:

Question11.Question :Please provide any information that will help in evaluation of your quiz.

Student Answer:This quiz required alot of testing before answering the questions. I dont have a enough space to see the code, had to cut and paste

Points Received:1 of 1

Comments:The short answer questions should not have a lot of code. That should warn you that you are probably off on a tangent.

* Times are displayed in (GMT-07:00) Mountain Time (US & Canada)

Q31.Question :What happens if you call a function with too few parameters?

Student Answer:NaN

Points Received:0 of 10

Comments:

Question2.Question :What value with myValue have after this computation:var myValue=72.925;myValue=parseInt(myValue);

Student Answer:72

Instructor Explanation:

Points Received:10 of 10

Comments:

Question3.Question :What expression can be used to compute the length of s1?var s1='99 bottles of beer';

Student Answer:var olu = s1.length;(A correct answer: s1.length)

Instructor Explanation:

Points Received:10 of 10

Comments:

Question4.Question :What happens if you call a function with too many parameters?

Student Answer:The function ignores other parameters, if they where defined. If the parameters were not defined you would get an not defined error

Points Received:5 of 10

Comments:They don't match parameter names, but they are not ignored.

Question5.Question :Is it possible to write a function in JavaScript that takes an arbitrary number of parameters? In one, concise sentence summarize why or why not.

Student Answer:Yes, by passing the function objects in a global object

Points Received:3 of 10

Comments:No. Review this area before the final exam. See the info on the 'arguments' pseudo-array

Question6.Question :Here is a function which is inconsistent in how it capitalizes rectangleArea.What does it return when called as getArea(4,5)?function getArea(w,h) { var rectangleArea; rectanglearea = w*h; return rectangleArea;}

Student Answer:undefined

Instructor Explanation:The function is returning the value of the uninitialized (and therefore undefined) var.

Points Received:10 of 10

Comments:

Question7.Question :What expression returns the number of elements in an array named myArray?

Student Answer:var olu = s1.length;(A correct answer: myArray.length)

Instructor Explanation:

Points Received:7 of 10

Comments:Wrong array!

Question8.Question :Given this code fragment, what is output to the log?var grades = [ 92, 94, 96.2 ];grades.push(89);grades.push(91);console.log(grades.pop());

Student Answer:91

Instructor Explanation:

Points Received:10 of 10

Comments:

Question9.Question :Please provide any information that will help in evaluation of your quiz.

Student Answer:I guess I need more training with functions.

Points Received:1 of 1

Comments:Please ask questions and we'll work our way through it!

* Times are displayed in (GMT-07:00) Mountain Time (US & Canada)

Q4 1.Question :Write a one-line statement that retrieves the "x" value of the object at index 7 in the array "myLocations" and assigns it to the variable "myLatitude".

Student Answer:var myLatitude = myLocations[7];(A correct answer: var myLatitude = myLocations[7].x;)

Instructor Explanation:

Points Received:6 of 10

Comments:missing the 'x'

Question2.Question :The model of the HTML page accessible to JavaScript is stored in the (please provide both the acronym and what the acronym stands for):

Student Answer:Document Object Model (DOM)

Instructor Explanation:DOMDocument Object Model

Points Received:10 of 10

Comments:

Question3.Question :Select the best description of the scope for the variable myVariable: // Line 0function myFunction(x,y) { // Line 1 var square; // Line 2 square = x*x + y*y; // Line 3 var myVariable = Math.sqrt(square); // Line 4 return myVariable; // Line 5} // Line 6

Student Answer:myVariable is visible globally (Line 0 to Line 6)

myVariable is visible from Line 2 through line 5

myVariable is visible from Line 4 to Line 5

None of the above

All of the above

Instructor Explanation:A var is "hoisted" to the top of the function block it is declared in.

Points Received:4 of 10

Comments:

Question4.Question :The finally clause of a try/catch/finally statement is executed (check as many as are true):

Student Answer:No matter what happens in the try/catch part of the block.

After the try block if at least one statment in it is executed, and after the catch block if it is invoked after that

After the try block if it is successfu

After the catch block if there is an exception raised

None of the above

Points Received:10 of 10

Comments:

Question5.Question :If a variable is declared twice within the same function, the second declaration:

Student Answer:Creates and initializes a brand new variable with the same name

Throws an Error

Logs a warning in the console

Is silently ignored and treated as an assignment.l

Points Received:1 of 10

Comments:

Question6.Question :What value is stored in msg?var headline="USA expects to do well in Sochi";var msg = headline.substr(0,3).toLowerCase();

Student Answer:"usa"(A correct answer: usa)

Instructor Explanation:

Points Received:10 of 10

Comments:

Question7.Question :Write an expression that retrieves the contents of the section of an HTML document with the id 'orchestra'

Student Answer:document.getElementById("orchestra");(A correct answer: document.getElementById('orchestra'))

Instructor Explanation:

Points Received:10 of 10

Comments:

Question8.Question :By coding convention, if a JavaScript function or object (like Date) begins with a capital letter, one creates it and assigns it to a var using the keyword

Student Answer:create

new

with

in

None of the above

Points Received:10 of 10

Comments:

Question9.Question :Which expression to assigns the contents of the text input field with id 'email' to the variable theEmail

Student Answer:var theEmail = email;

var theEmail = document.email;

var theEmail = document.getElementsByTagName('email');

var theEmail = window.document.getElementById('email');

var theEmail = document.getInputField('email');

Points Received:10 of 10

Comments:

Question10.Question :If an assignment is made in a function to a variable not declared in that function, the variable has what scope?

Student Answer:local to the function

global to the entire JavaScript runtime

restricted to the block it is defined in, as marked by curly braces

An error if "use strict"; is the first line of the function

It is temporary, in that statement only.

Points Received:6 of 10

Comments:

Question11.Question :Please provide any information that will help in evaluation of your quiz.

Student Answer:still working on functions

Points Received:1 of 1

Comments:

* Times are displayed in (GMT-07:00) Mountain Time (US & Canada)

Q5

1.Question :Because JavaScript does not have a class structure and hierarchy, it cannot support inheritance

Student Answer:TrueFalse (Darn tootin'JavaScript supports object inheritance.)

Points Received:0 of 10

Comments:Sorry! This is a topic which we went over most of last week when you were unfortunately gone.

Question2.Question :When an object (or function yielding an object) in JavaScript begins with a capital letter, this indicates

Student Answer:The object should be created using new

The object is really an Array

The object is a constant

The object has global scope

The object is important

Points Received:10 of 10

Comments:

Question3.Question :When an object method is invoked, and the object has not defined that method, its _____________ is checked next for the method

Student Answer:properties(A correct answer: prototype)

Instructor Explanation:

Points Received:2 of 10

Comments:

Question4.Question :In the following piece of code, Superman's archrival from the 5th dimension has injected his favorite number into 'person'. Does superman now have a mxyzptlk property?var person = {};var superman=Object.create(person);// Oh-oh! It's Mr. Mxyzptilk!person.mxyzptlk = 77;// Does superman have a mxyzptlk property now?

Student Answer:TrueFalse

Instructor Explanation:Putting a property in the parent or base object does carry through to all inheriting from it!

Worse yet, try deleting the property from superman!

Points Received:10 of 10

Comments:

Question5.Question :What method allows you to check if a property is actually in the variable you are checking, and not in an ancestor?

Student Answer:Enumerating Object Properties(A correct answer: hasOwnProperty)

Instructor Explanation:

Points Received:6 of 10

Comments:Yes, but through what method?

Question6.Question :For this code, what is the value output on the console?var w = { get jersey { return 77; }, name: 'Jeff''};w.jersey=10341;console.log(w.jersey);

Student Answer:77

10341

undefined

it is an error

Points Received:10 of 10

Comments:

Question7.Question :Since an object's properties are not indexed with integers, like an array, what construct is used to iterate over all of the properties of objectmyObjectusingvar p

Student Answer:for (var p in myObject)

Instructor Explanation:

Points Received:10 of 10

Comments:

Question8.Question :What is the difference betweensetTimeoutandsetInterval

Student Answer:setTimeout is about network traffic, and setInterval is about user events

setTimeout takes a function parameter and a time parameter, while setInterval takes an array parameter and a time parameter

setTimeout and setInterval do the same thing; one is the modern version of the other.

setTimeout fires one event, while setInterval repeatedly fires events

Points Received:10 of 10

Comments:

Question9.Question :Setting the location property of the document will navigate to whatever page it was assigned.

Student Answer:True (Fantastic, isn't it?)False

Points Received:10 of 10

Comments:

Question10.Question :JavaScript event handler functions are passed one parameter. What does that parameter represent?

Student Answer:eventlistener(A correct answer: event)

Instructor Explanation:

Points Received:5 of 10

Comments:It is the actual event

Question11.Question :Please provide any information that will help in evaluation of your quiz.

Student Answer:Great quiz.

Points Received:1 of 1

Comments:

* Times are displayed in (GMT-07:00) Mountain Time (US & Canada)

Q6

1.Question :The canvas, since it is an HTML5 element,cannotbe interacted with by programming in JavaScript.

Student Answer:TrueFalse

Points Received:10 of 10

Comments:

Question2.Question :The 'document', which is a property of the 'window' global in a browser is a:

Student Answer:Event representing a change in the HTML page

Function called to get parts of the HTML page

DOM representing the HTML page

Array containing the elements on the HTML page

An anachronism provided to confuse the unwary

Points Received:10 of 10

Comments:

Question3.Question :Which of the following was can document elements be selected and returned in the DOM API?

Student Answer:By id

By color

By CSS class

By CSS selector

By font

Points Received:8 of 10

Comments:

Question4.Question :When an event handler is called, what is the value of 'this'?

Student Answer:The global object

null

The event, also provided as a parameter

The source object of the event

The 'document' object

Points Received:2 of 10

Comments:

Question5.Question :Scalable Vector Graphics (SVG) drawings, which can be embedded in HTML documents, can also be created and edited by drawing editors such as Adobe Illustrator and InkScape

Student Answer:TrueFalse

Points Received:10 of 10

Comments:

Question6.Question :What goes in the blank to test if our event handler was triggered by a mouse event?function handler(e) { if ( e ___________ MouseEvent) { // Omitted code ... }}

Student Answer:.type ===(A correct answer: instanceof)

Instructor Explanation:

Points Received:5 of 10

Comments:

Question7.Question :When a 'var' is declared in an anonymous event handler function ,what scope does it have?

Student Answer:Globally scoped

Scoped to the containing function of the event handler

From the point of declaration to the end of the event handler function

Everywhere within in the event handler function

Points Received:10 of 10

Comments:

Question8.Question :Name the event method that keeps the default action from proceeding

Student Answer:preventDefault

Instructor Explanation:

Points Received:10 of 10

Comments:

Question9.Question :Creating a new 'p' element to put into the HTML document is done with:

Student Answer:var p = document.createElement('p');

var p = document.createTextNode('p');

var p = new Element('p');

var p = HTML.addParagraph();

var p = { };

Points Received:10 of 10

Comments:

Question10.Question :Adding the newly created element stored in p, and adding it as a child of the element with id 'status' is done with:

Student Answer:document['status'] += p;

document.getElementById('status').appendChild(p);

document['status'].push(p);

document.getElementById('status').push(p);

document.addAfter('status',p);

Points Received:10 of 10

Comments:

Question11.Question :Please provide any information that will help in evaluation of your quiz.

Student Answer:Trying to better understand the mathematics representation of DOM

Points Received:1 of 1

Comments:

* Times are displayed in (GMT-07:00) Mountain Time (US & Canada)

Q7

1.Question :A single event (say, a MouseEvent) in JavaScript can be handled by two different handlers

Student Answer:TrueFalse

Instructor Explanation:This is the job of addEventHandler

Points Received:10 of 10

Comments:

Question2.Question :What is passed as the parameter to an event handler?

Student Answer:events(A correct answer: event)

Instructor Explanation:

Points Received:10 of 10

Comments:

Question3.Question :In the previous problem, you might have checked your answers using this string function:

function chkStringMatch(string, regularExpression) { if ( string.______________(regularExpression) ) { return true; } return false;}

Student Answer:regex

match

pattern

strike

trim

Points Received:10 of 10

Comments:

Question4.Question :Which of the following string inputs will match this regular expression?

/[A-Z]{2}[0-9]/

Student Answer:Welcome to ICT4570(Matches CT4)

This course is loads of fun! Even if I have to drive down I25(The I25 doesn't match. We need 2 letters and one number.)

I usually head up to the mountains in my RX7

After I put on WD40, everything works better!(Matches WD4)

I have to begin preparing the IRS 1040 for my taxes(The space spoils it.)

Points Received:6 of 10

Comments:

Question5.Question :A single event handler can handle multiple events

Student Answer:TrueFalse

Instructor Explanation:Absolutely.

Points Received:10 of 10

Comments:

Question6.Question :If we want to check many things against a regular expression, we might create a function as follows. What RegEx method is used to fill in the blank?

function chkRegEx(regEx,string) { if ( regEx._____________(string) ) { return true; } return false;}

Student Answer:test

Instructor Explanation:

Points Received:10 of 10

Comments:

Question7.Question :An HTML canvas can support event handlers

Student Answer:TrueFalse

Points Received:10 of 10

Comments:

Question8.Question :Scalable Vector Graphics (SVG) elements can support event handlers

Student Answer:TrueFalse

Points Received:10 of 10

Comments:

Question9.Question :What object's methods are needed to draw on a canvas?

Student Answer:fillStyle,fillRect,arc(A correct answer: context)

Instructor Explanation:

Points Received:3 of 10

Comments:These are the drawers--but not the object, which is the context.

Question10.Question :In the following function, what operator can be placed in the blank to check if e is derived from a Date?

function chkIfDate(d) { if ( d ___________ Date ) { return true; } return false;}

Student Answer:typeof(A correct answer: instanceof)

Instructor Explanation:

Points Received:5 of 10

Comments:Almost

Question11.Question :Please provide any information that will help in evaluation of your quiz.

Student Answer:Not sure about question 4, reviewed it a few times and still came up with same answer. Not sure if question was clear enough

Points Received:1 of 1

Comments:

* Times are displayed in (GMT-07:00) Mountain Time (US & Canada)