Sample CS 142 Midterm Examination

Similar documents
Sample CS 142 Midterm Examination

Sample CS 142 Midterm Examination

CS142 Winter 2017 Midterm Grading Solutions and Rubric

CS 142 Final Examination

Javascript Performance in the Browser. Charlie Fiskeaux II User Interface Engineer

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

CIS 228 (Spring, 2012) Final, 5/17/12

CS193X: Web Programming Fundamentals

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

INFS 2150 Introduction to Web Development

INFS 2150 Introduction to Web Development

HTML + CSS. ScottyLabs WDW. Overview HTML Tags CSS Properties Resources

Using CSS for page layout

CSE 154: Web Programming Autumn 2018

CS 140 Midterm Examination Winter Quarter, 2012

Page Layout. 4.1 Styling Page Sections 4.2 Introduction to Layout 4.3 Floating Elements 4.4 Sizing and Positioning

Let's see a couple of examples

Best Practices Chapter 5

Introduction to WEB PROGRAMMING

CSC Website Design, Spring CSS Flexible Box

Client-Side Web Technologies. CSS Part II

Welcome Please sit on alternating rows. powered by lucid & no.dots.nl/student

Ministry of Higher Education and Scientific Research

How to lay out a web page with CSS

Acknowledgments. Who Should Read This Book?...xxiv How to Read This Book...xxiv What s in This Book?...xxv Have Fun!...xxvi

Taking Fireworks Template and Applying it to Dreamweaver

PIC 40A. Midterm 1 Review

COMP519 Web Programming Lecture 8: Cascading Style Sheets: Part 4 Handouts

Styles, Style Sheets, the Box Model and Liquid Layout

COMM 2555: Interactive Digital Communication / Spring 2018 Lab 9: Basic layout techniques with CSS

First Name Last Name CS-081 March 23, 2010 Midterm Exam

Advanced Dreamweaver CS6

HTML & CSS. SWE 432, Fall 2017 Design and Implementation of Software for the Web

BA. (Hons) Graphics Design

Chapter 3 Style Sheets: CSS

Data Visualization (CIS 468)

CSC Web Programming. JavaScript Browser Objects

How to lay out a web page with CSS

CSE 154: Web Programming Autumn 2018

As we design and build out our HTML pages, there are some basics that we may follow for each page, site, and application.

CSS Selectors. element selectors. .class selectors. #id selectors

Notes - CSS - Flexbox

Data Visualization (CIS/DSC 468)

Getting Started with CSS Sculptor 3

CSS MOCK TEST CSS MOCK TEST III

BA. (Hons) Graphics Design

INFS 2150 Introduction to Web Development

INFS 2150 Introduction to Web Development

Perfect Student Midterm Exam March 20, 2007 Student ID: 9999 Exam: 7434 CS-081/Vickery Page 1 of 5

Web Engineering CSS. By Assistant Prof Malik M Ali

Financial. AngularJS. AngularJS.

CSS for Page Layout Robert K. Moniot 1

Web Programming and Design. MPT Senior Cycle Tutor: Tamara Week 2

Block & Inline Elements

Financial. AngularJS. AngularJS. Download Full Version :

JavaScript: Objects, BOM, and DOM CS 4640 Programming Languages for Web Applications

Chapter 1 Introduction to Dreamweaver CS3 1. About Dreamweaver CS3 Interface...4. Creating New Webpages...10

Web Design and Development ACS Chapter 12. Using Tables 11/23/2017 1

Cascading style sheets, HTML, DOM and Javascript

subject to an additional IP rights grant found at polymer.github.io/patents.txt -->

COMS 359: Interactive Media

University of Washington, CSE 154 Homework Assignment 8: Baby Names

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

How to lay out a web page with CSS

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) More on Relative Linking. Learning Objectives (2 of 2)

Create a three column layout using CSS, divs and floating

Varargs Training & Software Development Centre Private Limited, Module: HTML5, CSS3 & JavaScript

9 Introducing Drag and Drop Techniques

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

Web Site Design and Development Lecture 9. CS 0134 Fall 2018 Tues and Thurs 1:00 2:15PM

Introducing CSS Flexbox Layout

Layout Manager - Toolbar Reference Guide

Cascading Style Sheets (CSS)

Using Dreamweaver CS6

welcome to BOILERCAMP HOW TO WEB DEV

Introduction to HTML & CSS. Instructor: Beck Johnson Week 5

CSS3 Basics. From & CSS Visual Dictionary Learning Curve Books, LLC

Tutorial 2 Editor Brackets

BA. (Hons) Graphics Design

Fixed Size Ad Specifications

This is an open-book, open-notes, open-computer exam. You may not consult with anyone other than the instructor while working on this exam.

JavaScript and Objects CS 4640 Programming Languages for Web Applications

CSS: Layout, Floats, and More

Javascript. Many examples from Kyle Simpson: Scope and Closures

Flexible and LEAN Ads

Zen Garden. CSS Zen Garden

IMY 110 Theme 11 HTML Frames

Web Design and Implementation

Ignite UI Release Notes

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

Adding CSS to your HTML

Web Design and Development Tutorial 03

Dreamweaver CS4. Introduction. References :

Student, Perfect Final Exam May 25, 2006 ID: Exam No CS-081/Vickery Page 1 of 6

Adobe Dreamweaver CS6 Digital Classroom

UNIVERSITI TEKNOLOGI MALAYSIA TEST 1 SEMESTER II 2012/2013

Ignite UI Release Notes

ABOUT WEB TECHNOLOGY COURSE SCOPE:

Web Development & Design Foundations with HTML5

Appendix D CSS Properties and Values

Transcription:

Sample CS 142 Midterm Examination Spring Quarter 2016 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 #9 Total Score Max 10 11 12 12 9 12 8 10 6 90 1

Problem #1 (10 points) Consider the following JavaScript program. Each console.log call has a comment with blank slot after. In each slot write what the console.log would print out if you were to run this program. console.log(a); // log1 var a = 3; function foo(x) { console.log(x); // log2 var c = 10; x = 20; console.log(a); // log3 a = 4; return func; function func (d) { c = d; x *= 2; return { a: a, c: c, x: x }; } } console.log(a); // log4 var bar = foo(a); console.log(a); // log5 var retval = bar(3); console.log(retval.a); // log6 retval = bar(5); console.log(retval.c); // log7 console.log(retval.x); // log8 console.log(a); // log9 console.log(retval.func); // log10 2

Problem #2 (11 points) (A) The following JavaScript program creates two objects named "obj" and "proto" and sets the prototype of obj to be proto. For each of the console.log statements in the program, write the three numbers (or the word undefined if the value printed would be undefined) in the provided slots on the side. var proto = {a: 1, b: 2, c: 3}; var obj = {a: 0}; obj. proto = proto; // T his sets the object's prototype to be the proto console.log(obj.a, obj.b, obj.c); // log1,, proto.a = 5; proto.b = 6; proto.c = 7; console.log(obj.a, obj.b, obj.c); // log2,, obj.a = 9; obj.b = 8; console.log(proto.a, proto.b, proto.c); // log3,, console.log(obj.a, obj.b, obj.c); // log4,, (B) What is the difference between adding a method to a class via the prototype pattern versus. assigning the method to the constructed object in the object's constructor? 3

Problem #3 (12 points) (A) Given an HTML page with a button element, with id of "button" and the following JavaScript: console. log ( "A" ); settimeout ( function () { console. log ( "B" ); }, 1000 ); console. log ( "C" ); settimeout ( function () { console. log ( "D" ); }, 1500 ); document. getelementbyid ( "button" ). onclick = function () { console. log ( "E" ); console. log ( "F" ); } Assuming the JavaScript is executed when the window is loaded, and a user clicks on the element with id "button" at some point, circle the following console outputs which are possible (there may be more than one). A B C D E F A C B E F D A C B E D F A C E B F D A C E F B D (B) If you had both a capture phase listener and a bubble phase listener for a click event on a DOM element, which would expect to run first if you clicked on the element? Briefly justify your answer. How about if you click on a child element of the element with the listener registered? Briefly justify your answer. 4

Problem #4 (12 points) You are given an HTML page with four square <div> elements of class "box" that causes the browser to place blocks across a row as shown below in the "Initial box layout". For each of the additional CSS rules, please write the ID of the div in the box where it appears. Note: If top/bottom/left/right are not defined, the values default to auto, which is calculated by the browser. inline-block elements are like inline elements but they can have a width and a height, allowing us to render our boxes horizontally. HTML <div id = "A" class = "box" > A </div> <div id = "B" class = "box" > B </div> <div id = "C" class = "box" > C </div> <div id = "D" class = "box" > D </div> Initial box layout: A). box { height : 100px; width : 100px; display : inline - block; border : 2px solid black; } CSS #A { position : relative; top : 0px; } #B { position : relative; top : 0px; } #C { position : relative; top : 0px; } #D { position : absolute; top : 100px ; } B) CSS #A { position : absolute; top : 100px; } #B { position : relative; top : 0px; } #C { position : relative; top : 0px; } #D { position : relative; top : 100px ; } 5

Problem #5 (9 points) (A) Angular claims to support two-way binding. What does two-way binding mean? (B) What mechanisms does Angular use to achieve two-way binding? (C) Describe what would happen to an Angular Web Application if you deleted the ng-app attribute from the main view template. What would be displayed on the screen? 6

Problem #6 (12 points) (A) @media queries allow CSS selectors to be based on device size. Given the large number of different device sizes, how do modern frameworks use media queries to make sure their layouts look appropriate across all device sizes? (B) Given the flexibility of CSS selectors, it is easy to write two rules that contain different selectors yet both end up matching a particular DOM element. For example, a selector might match on just the element (e.g. "p") or the element and a class (e.g. "p.class1"). What does CSS do if a stylesheet has two different rules with different selectors like these that match a single DOM element? (C) Explain the difference between display : block and display : inline. (D) When specifying position : relative, what is the element relative to? 7

Problem #7 (8 points) (A) How are invalid characters such as spaces used in query parameters? (B) Label the parts (query parameters, server s port number, hierarchical portion, host name, scheme, and fragment) of the following URL along with a short(1-2 sentence) description of that part. file://host.cs142.com:50/animal/bird/penguin.html?user=mendel#h3 8

Problem #8 (10 points) (A) Describe what is meant by web applications that: (1) Support deep-linking? (2) Are responsive? (B) Describe a way of building web applications supporting languages of different countries that doesn't require multiple view templates for the same view. 9

Problem #9 (6 points) (A) Explain why <b> and <i> are considered not good practice in HTML. (B) List three things that can go in an HTML <head> section. 10