Sample CS 142 Midterm Examination

Similar documents
Sample CS 142 Midterm Examination

CS142 Winter 2017 Midterm Grading Solutions and Rubric

Sample CS 142 Midterm Examination

CS 142 Final Examination

CS 140 Midterm Examination Winter Quarter, 2012

Midterm Exam. 5. What is the character - (minus) used for in JavaScript? Give as many answers as you can.

AngularJS Introduction

Project 3 CIS 408 Internet Computing

Front End Programming

Platform. Custom Embedded Tabs. Custom Embedded Tab Definitions. Custom Embedded Tabs, page 1

Problem Description Earned Max 1 HTML / CSS Tracing 20 2 CSS 20 3 PHP 20 4 JS / Ajax / JSON 20 5 SQL 20 X Extra Credit 1 TOTAL Total Points 100

CS140 Operating Systems and Systems Programming Midterm Exam

Financial. AngularJS. AngularJS.

Custom Embedded Tabs, on page 1 Configure Cisco Jabber for Android on Chromebook, on page 8 Cisco Jabber Mobile App Promotion, on page 9

Financial. AngularJS. AngularJS. Download Full Version :

AJAX: The Basics CISC 282 March 25, 2014

JavaScript Lecture 3c (jquery)

CSC Web Programming. JavaScript Browser Objects

Javascript. Many examples from Kyle Simpson: Scope and Closures

Building Web Applications

INLEDANDE WEBBPROGRAMMERING MED JAVASCRIPT INTRODUCTION TO WEB PROGRAMING USING JAVASCRIPT

Single Page Applications

AJAX: The Basics CISC 282 November 22, 2017

Project 3 Web Security Part 1. Outline

CS 155 Final Exam. CS 155: Spring 2009 June 2009

What is AngularJS. à Javascript Framework à MVC à for Rich Web Application Development à by Google

Web Application Security

PIC 40A. Midterm 1 Review

Comp 426 Midterm Fall 2013

JavaScript and XHTML. Prof. D. Krupesha, PESIT, Bangalore

Client-side Debugging. Gary Bettencourt

CSc 337 LECTURE 15: REVIEW

COMP 2406: Fundamentals of Web Applications. Fall 2013 Mid-Term Exam Solutions

JavaScript: the Big Picture

iwiki Documentation Release 1.0 jch

Introduction to JavaScript p. 1 JavaScript Myths p. 2 Versions of JavaScript p. 2 Client-Side JavaScript p. 3 JavaScript in Other Contexts p.

1. Launch the Seaside One-Click Experience (see Chapter 1 for details) and open a web browser on

Understanding this structure is pretty straightforward, but nonetheless crucial to working with HTML, CSS, and JavaScript.

Getting MEAN. with Mongo, Express, Angular, and Node SIMON HOLMES MANNING SHELTER ISLAND

Part 1 (80 points) Multiple Choice Questions (20 questions * 4 points per question = 80 points)

JavaScript Lecture 1

JavaScript. What s wrong with JavaScript?

MVC: Model View Controller

SCRIPT REFERENCE. UBot Studio Version 4. The UI Commands

JavaScript Programming

AngularJS Intro Homework

AngularJS AN INTRODUCTION. Introduction to the AngularJS framework

CS140 Operating Systems and Systems Programming Midterm Exam

CITS1231 Midterm Test (A total of 45 marks)

ANGULARJS - MOCK TEST ANGULARJS MOCK TEST II

Student, Perfect Midterm Exam March 24, 2006 Exam ID: 3193 CS-081/Vickery Page 1 of 5

CS142 - Web Applications

Assignment: Seminole Movie Connection

Using Development Tools to Examine Webpages

Microsoft Exam

Functions. Functions in JavaScript are declared using the function keyword

Introduction to Dreamweaver CS4:

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML

CS140 Operating Systems and Systems Programming Midterm Exam

Problem Description Earned Max 1 HTML / CSS Tracing 20 2 CSS 20 3 PHP 20 4 JS / Ajax / JSON 20 5 SQL 20 X Extra Credit 1 TOTAL Total Points 100

Overview. Event Handling. Introduction. Reviewing the load Event. Event mousemove and the event Object. Rollovers with mouseover and mouseout

LING 408/508: Computational Techniques for Linguists. Lecture 14

React. HTML code is made up of tags. In the example below, <head> is an opening tag and </head> is the matching closing tag.

ENGR 100 Midterm (CSE Part) Winter 2014

Do not start the test until instructed to do so!

Short Answer Questions (40 points)

Brief Intro to Firebug Sukwon Oh CSC309, Summer 2015

ANGULARJS INTERVIEW QUESTIONS

! The final is at 10:30 am, Sat 6/4, in this room. ! Open book, open notes. ! No electronic devices. ! No food. ! Assignment 7 due 10pm tomorrow

Technical Specifications Leaderboard + Mobile Leaderboard. 27/12/2018 Tech Specs 1

Final Exam CS164, Fall 2007 Dec 18, 2007

CSE 154: Web Programming Autumn 2018

Events & Callbacks (ESaaS 6.5)! 2013 Armando Fox & David Patterson, all rights reserved

INTRODUCTION TO JAVASCRIPT

University of Washington, CSE 190 M Homework Assignment 8: Baby Names

Developer Guide / dev_guide / e2e-testing

Rico AjaxEngine Tutorial

CIW 1D CIW JavaScript Specialist.

CS 140: Operating Systems and Systems Programming Midterm Exam

Proper_Name Final Exam December 21, 2005 CS-081/Vickery Page 1 of 4

NetAdvantage for jquery SR Release Notes

3 Days Training Program

5/19/2015. Objectives. JavaScript, Sixth Edition. Understanding Syntax Errors. Introduction to Debugging. Handling Run-Time Errors

Problem Possible Points Points Earned Problem Possible Points Points Earned Test Total 100

Unobtrusive JavaScript (Sample Chapter)

Web Application Development

Vue.js Framework. Internet Engineering. Spring Pooya Parsa Professor: Bahador Bakhshi CE & IT Department, Amirkabir University of Technology

Visual Web Next Design Concepts. Winston Prakash Feb 12, 2008

VTU Question Bank. UNIT 1 Introduction to WWW, XHTML

Adobe Dreamweaver CS4

0.9: Faster, Leaner and Dijit? July 25, 2007 Dylan Schiemann. presented by

PASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year

Course Details. Skills Gained. Who Can Benefit. Prerequisites. View Online URL:

COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2018)

CS140 Operating Systems and Systems Programming Final Exam

Frontend II: Javascript and DOM Programming. Wednesday, January 7, 15

Eng 110, Spring Week 03 Lab02- Dreamwaver Session

2/6/2012. Rich Internet Applications. What is Ajax? Defining AJAX. Asynchronous JavaScript and XML Term coined in 2005 by Jesse James Garrett

COMP519 Web Programming Lecture 16: JavaScript (Part 7) Handouts

JavaScript: Events, the DOM Tree, jquery and Timing

Transcription:

Sample CS 142 Midterm Examination Winter Quarter 2017 You have 1.5 hours (90 minutes) for this examination; the number of points for each question indicates roughly how many minutes you should spend on that question. Make sure you print your name and sign the Honor Code below. During the examination you may consult two double-sided pages of notes; all other sources of information, including laptops, cell phones, etc. are prohibited. I acknowledge and accept the Stanford University Honor Code. I have neither given nor received aid in answering the questions on this examination. (Signature) (Print your name, legibly!) (Stanford email account for grading database key) Problem #1 #2 #3 #4 #5 #6 #7 #8 Total Score Max 12 12 12 10 12 10 12 10 90 1

Problem #1 (12 points) Using the following HTML document say what the DOM accessing JavaScript expressions listed below would return. <html> <body id="body"> <table id="robots" class="goodbots"> <tbody> <tr id="names" class="myheaderclass"> <th id="dolores">dolores</th> <th id="bernard">bernard</th> <th id="maeve">maeve</th> </tr> <tr id="age" class="myrowclass"> <td id="150" class="agesclass">150</td> <td id="findme" class="agesclass"> <span id="sneakyspan">100</span> </td> <td id="60" class="agesclass">60</td> </tr> <tr id="gender" class="myrowclass"> <td id="femaleone">f</td> <td id="male">m</td> <td></td> </tr> </tbody> </table> </body> </html> a) document.getelementbyid("findme").classname b) document.getelementbyid("findme").parentnode.classname c) document.getelementbyid("findme").parentnode.parentnode. parentnode.id Continued on next page... 2

Continued from previous page Hint: nextelementsibling and previouselementsibling are like nextsibling and previoussibling except they skip over DOM nodes representing the whitespace in the HTML. d) document.getelementbyid("findme").parentnode. nextelementsibling.id e) document.getelementbyid("sneakyspan").parentnode. previouselementsibling.id f) document.getelementsbytagname("td")[2].id 3

Problem #2 (12 points) var object = {numprop: 1, stringprop: "foo", obj1prop: {prop: 'foo'}}; object. proto = { stringprop: "bar", obj1prop: {prop: 'bar'}, obj2prop: {}}; print("1", object); print("1p", object. proto ); object.numprop = 2; object.stringprop = "foo2"; object.obj1prop.prop = "prop2"; object.obj2prop.prop = "prop2" print("2", object); print("2p", object. proto ); function print(tag, obj) { console.log(tag, "numprop", obj.numprop, "stringprop", obj.stringprop, "obj1prop", obj.obj1prop, "obj2prop", obj.obj2prop); } When the above code is executed it prints four lines to the console log. Each line contains four properties from either the object or its prototype. Fill in what this code would output in the form below. Assume console.log prints the entire object (e.g. console.log({prop: 'foo'}) prints '{prop: "foo"}'. Hint: The property proto returns the prototype of an object. 1 numprop stringprop obj1prop obj2prop 1p numprop stringprop obj1prop obj2prop 2 numprop stringprop obj1prop obj2prop 2p numprop stringprop obj1prop obj2prop 4

Problem 2 continued var globalvar = 1; function foo(argvar) { var localvar = 2; } return function (arg) { argvar += arg; localvar += arg; globalvar += arg; console.log('f', argvar, localvar, globalvar); }; var func1 = foo(1); var func10 = foo(10); func1(1); func10(2); console.log('g', globalvar); Show what the above code will output to the console log when executed. 5

Problem #3 (12 points) Given the URL http://web.stanford.edu/class/cs142/exams.html?v=win1617#midterm (A) Please fill in the blanks: URL Part Host name Hierarchical portion Example URL Section?v=win1617 http: #midterm (B) Without using a full URL, complete the HTML snippets below, making sure to write the shortest possible link to get to the URL above if: The browser is currently at http://web.stanford.edu/class < > Link A </ > The browser is currently at http://web.stanford.edu/schedule < > Link B </ > (C) List two additional uses for a URL, beyond loading a page in a web browser. (D) What is referential integrity? Does the modern web have it? Why or why not? 6

Problem #4 (10 points) (a) Angular's Directive abstraction is intended to aid in building reusable components. Like most things accessed during the Angular compilation phase using a Directive will generate a new Angular Scope and and that Scope will be a child of where the directive is invoked. Angular also supports defining Directives that although they get a new scope it does not act as a child scope. The directive is given what is called an isolated scope. The Directive definition specifies the content. To support reusable components Angular strongly recommends that isolated scopes be used for all Directives. Briefly explain why Angular recommends this. (b) Angular marketing material claims it supports "two-way binding". Briefly state what are the two ways including a description of the source and the destination of the "way". 7

Problem #5 (12 points) Given the following simple HTML document that contains the word "Div" and some JavaScript that registers event handlers on it. <html> <body id="body"> <div id="div">div</div> </body> </html> document.getelementbyid("body").addeventlistener("click", function (e) {console.log('body-true', e.target===e.currenttarget)}, true); document.getelementbyid("body").addeventlistener("click", function (e) {console.log('body-false', e.target===e.currenttarget)}, false); document.getelementbyid("div").addeventlistener("click", function (e) { console.log('div-true', e.target===e.currenttarget)}, true); document.getelementbyid("div").addeventlistener("click", function (e) { console.log('div-false',e.target===e.currenttarget)}, false); (Hint: The documentation for addeventlistener names its last parameter usecapture.) (a) Describe what would be printed to the console.log if you clicked on the word "Div". (b) Describe what would be printed to the console log if you clicked on the page but not on or near the word "Div". 8

Problem #6 (10 points) (a) A browser-based URL routing package such as Angular's ngroute wants to assign different URLs to different views so that browser navigation (e.g. forward/back buttons, history) can be used to navigate among the views. A browser normally restarts a fresh JavaScript Virtual Machine when navigating to a different page. Explain how a browser-based URL routing package can have different views without this JavaScript restart. (b) Although a single page application can use browser navigation controls, the browser refresh button (e.g. ) cannot be disabled so a good single page application will have the refresh restore the application to the place at which the refresh occurred. Describe how this functionality can be supported even in the face of the browser tossing all the JavaScript state. 9

Problem #7 (12 points) For each of the following web application functionality items, state which component (model, view, or controller) you would expect to expand in size the most when you add the functionality item to a web page. Provide a brief justification of your answer and make sure your answer demonstrates that you know what the functionality item is. (a) Responsive design (b) Internationalization (I18N) support (c) Accessible Rich Internet Applications (ARIA) support 10

Problem #8 (10 points) <html> <body> <div id="div1">div1</div> <div id="div2" class="class1">div2</div> <div>div3 <span id="span1" class="class1">span1</span> <span id="span2" class="class2">span2</span> </div> <div>div4</div> <span>span3</span> </body> </html> For each of the following CSS rule(s), write the words (e.g. Div2 ) that will appear red or green in the browser and specify the color. If a word does not have a red or green color you should not write it down. Rules from one part do not apply to the next part. Briefly justify your answers for each part by stating what the CSS rules are doing. (a) div { color: red} (b) div.class1 { color: red} (c).class1 { color: red} Problem continued on next page. 11

.Continued from previous page (d) #span2 {color: red} (e) div { color: red} div.class1 {color: green} 12