CSCI 201L Final Written Spring % of course grade

Similar documents
Final Score ID Extra Credit. 15% of course grade

Final Score Name SOLUTION ID Extra Credit. 15% of course grade

Final Score Name SOLUTION ID Extra Credit. 10% of course grade

Final Score ID Extra Credit. 15% of course grade

Spring % of course grade

CSCI 201L Written Exam #1 Fall % of course grade

Final Score ID Extra Credit. 10% of course grade

CSCI 201L Written Exam #1 Fall % of course grade

15% of course grade. Final Score ID Extra Credit. Name SOLUTION. Section (circle one): TTh 8:00-9:20 TTh 9:30-10:50 TTh 11:00-12:20

CSCI 201L Written Exam #2. 10% of course grade

Multi-Threaded Programming Design CSCI 201 Principles of Software Development

CMSC 330: Organization of Programming Languages. Threads Classic Concurrency Problems

CMSC 330: Organization of Programming Languages. The Dining Philosophers Problem

CMSC 132: Object-Oriented Programming II. Threads in Java

Project. Threads. Plan for today. Before we begin. Thread. Thread. Minimum submission. Synchronization TSP. Thread synchronization. Any questions?

CSCI 201L Final Written SOLUTION. 13% of course grade

Developing Applications with Java EE 6 on WebLogic Server 12c

Threads and Locks, Part 2. CSCI 5828: Foundations of Software Engineering Lecture 08 09/18/2014

Midterm Exam Amy Murphy 19 March 2003

Chapter 32 Multithreading and Parallel Programming

27/04/2012. We re going to build Multithreading Application. Objectives. MultiThreading. Multithreading Applications. What are Threads?

CSE 336. Introduction to Programming. for Electronic Commerce. Why You Need CSE336

Getting Started in Your Blackboard 5 Course

CS506 Web Design & Development Final Term Solved MCQs with Reference

Synchronization in Concurrent Programming. Amit Gupta

The Dining Philosophers Problem CMSC 330: Organization of Programming Languages

Oral Question Bank for CL-3 Assignment

Basic Principles of analysis and testing software

Threads and Java Memory Model

CS 450 Exam 2 Mon. 11/7/2016

Synchronized Methods of Old Versions of Java

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

CMSC 330: Organization of Programming Languages

Java SE7 Fundamentals

Summary Semaphores. Passing the Baton any await statement. Synchronisation code not linked to the data

Week 7. Concurrent Programming: Thread Synchronization. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

CS61B, Spring 2003 Discussion #17 Amir Kamil UC Berkeley 5/12/03

1Z Oracle. Java Platform Enterprise Edition 6 Enterprise JavaBeans Developer Certified Expert

G52CON: Concepts of Concurrency

Principles of Concurrent Programming TDA384/DIT391

More Synchronization; Concurrency in Java. CS 475, Spring 2018 Concurrent & Distributed Systems

JAVA EXAMPLES - SOLVING DEADLOCK

Threads and Locks. CSCI 5828: Foundations of Software Engineering Lecture 09 09/22/2015

CIS 3308 Web Application Programming Syllabus

Producer/Consumer CSCI 201 Principles of Software Development

Computation Abstractions. CMSC 330: Organization of Programming Languages. So, What Is a Thread? Processes vs. Threads. A computer.

BlockingArrayQueue.java. Page 1

SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (II)

Game100 Networking Lab 4. Part 1 (5.1.4) Using the Windows Calculator with Network Addresses

Multitasking Multitasking allows several activities to occur concurrently on the computer. A distinction is usually made between: Process-based multit

COMPSCI 230 Threading Week8. Figure 1 Thread status diagram [

Buch gefunden? Im Blackboard eingetragen? Abgabe 1. Übung: , 23:59

More thread safety and Concurrent collections. Nasser Giacaman CompSci 230: Software Design and Construction

JFokus Finding And Solving Java Deadlocks

CS Final Exam Review Suggestions - Spring 2018

Blackboard: Campus Pack Journal Sites

Lesson 12: JavaScript and AJAX

Multithreading. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark

Computation Abstractions. Processes vs. Threads. So, What Is a Thread? CMSC 433 Programming Language Technologies and Paradigms Spring 2007

Threads and Parallelism in Java

Java Threads Vs Processes. CS Concurrent Programming. Java Threads. What can a thread do? Java Concurrency

CSCD 330 Network Programming

Midterm Exam 2 CS 455, Spring 2015

CMSC 132: Object-Oriented Programming II

CMSC 330: Organization of Programming Languages

CSCI 201L Syllabus Principles of Software Development Spring 2018

Midterm Exam. CS169 Fall November 17, 2009 LOGIN: NAME: SID: Problem Max Points Points TOTAL 100

CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2013

Synchronization SPL/2010 SPL/20 1

CMSC 433 Programming Language Technologies and Paradigms Fall Locks & Conditions

CMSC 433 Section 0101 Fall 2012 Midterm Exam #1

Faculty Guide to Blackboard

CSCD 330 Network Programming

ITEC 350: Introduction To Computer Networking Midterm Exam #2 Key. Fall 2008

Synchronization in Java

Final Exam CS164, Fall 2007 Dec 18, 2007

CSE 332 Winter 2018 Final Exam (closed book, closed notes, no calculators)

1. Introduction. 2. Project Submission and Deliverables

CPS 110 Final Exam. Spring 2011

CSE 143 Lecture 14. Interfaces; Abstract Data Types (ADTs) reading: 9.5, 11.1; 16.4

ECE 462 Exam 3. 11:30AM-12:20PM, November 17, 2010

ECE 462 Fall 2011, Third Exam

The NoPlsql and Thick Database Paradigms

SAS Solutions for the Web: Static and Dynamic Alternatives Matthew Grover, S-Street Consulting, Inc.

THIS EXAMINATION PAPER MUST NOT BE REMOVED FROM THE EXAMINATION ROOM

Threads Chate Patanothai

Midterm Exam CS 251, Intermediate Programming March 12, 2014

JS Event Loop, Promises, Async Await etc. Slava Kim

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

MultiThreading 07/01/2013. Session objectives. Introduction. Introduction. Advanced Java Programming Course

Advanced Java Programming Course. MultiThreading. By Võ Văn Hải Faculty of Information Technologies Industrial University of Ho Chi Minh City

<Insert Picture Here>

Punjab Technical University Bachelor in Mobile Computing & Internet Batch 2014 onwards THIRD SEMESTER

Splitting the pattern into the model (this stores and manipulates the data and executes all business rules).

re-exam Concurrent Programming tda383/dit390 Date: Time: 14:00 18:00 Place: Maskinhuset (M)

Concurrency & Multithreading

"Web Age Speaks!" Webinar Series

COMP 322: Fundamentals of Parallel Programming

Student Quick Start Guide

CSC 111, Test 1 (Fall 2009)

Transcription:

Name SOLUTION Final Score ID Extra Credit Section (circle one): MW 8:30-9:50 TTh 9:30-10:50 TTh 11:00-12:20 12% of course grade 1. Servlets Explain the difference between a GET and POST form submission. Give one reason why a programmer would choose to use a GET and one reason why a programmer would choose to use a POST. (0.5% + 0.5% + 0.5%) Difference A GET will submit the data along the URL. (http://localhost/index.html?user=root&pass=yep) A POST will submit the data in the body of the request. Why programmer would choose to use GET Allow bookmarking of a page. Able to be read in JavaScript (client-side). Allows user to change the parameters in the URL. Why programmer would choose to use POST Hide the data from being seen by the user. Not able to be accessed on the client-side. If uploading a file, POST must be used. 2. Software Engineering The Mythical Man-Month by Fred Brooks claims that it takes 9 times as long to create a software product system compared to just creating a program. Give two reasons why it takes significantly longer to create a software product system. (0.5% + 0.5%) 1. Significant documentation is required for programmers. 2. Documentation may be required for users. 3. Extensive testing needed. 4. More detailed requirements necessary. 5. Better design of system. 6. May need to meet government regulations. 7. Other answers may be correct. 1/7

3. AJAX and Web Sockets AJAX and Web Sockets both allow a web page to be updated without needing to refresh the page. Explain what AJAX is and what Web Sockets are. Why would a programmer choose to use one over the other? (0.5% + 0.5% + 0.5% + 0.5%) Define AJAX Asynchronous JavaScript and XML (AJAX) allows calls to the server to take place asynchronously, which will then allow part of an HTML page to be updated without needing to refresh the page. Define Web Sockets Web Sockets allows persistent communication between the browser and the server. The communication can be initiated by the server, different from other HTTP communication. Why programmer would choose AJAX If only part of the page needs to be updated based on the user performing some action, AJAX would be used. Why programmer would choose Web Sockets If only part of the page needs to be updated based on the server initiating the action, Web Sockets would be used. 4. Concurrent Programming - What is the primary goal of each of the three types of concurrent programming? (0.5% + 0.5% + 0.5%) Multi-threading Add functionality since two threads are executing at what appears to be simultaneously to the user. Parallel Make the program execute faster because more than threads are actually executing simultaneously in different cores in a shared memory space. Distributed Make the program execute faster because threads are executing in different cores in different memory spaces, typically on different computers. 2/7

5. Networking Theory Assume you are given the following IP address and subnet mask. IP 120.192.168.50 IP 0111 1000 1100 0000 1010 1000 0011 0010 Subnet Mask 255.255.248.0 Subnet Mask 1111 1111 1111 1111 1111 1000 0000 0000 a. What class IP address is given? What is the network address? (0.5%) Class A 120.0.0.0 b. Is the IP address public or private? (0.5%) public c. How many hosts can be on the subnetwork? (0.5%) 2046 (2 11 2 for the network and broadcast addresses) d. What is the network and subnetwork combination? (0.5%) 120.192.168.0 6. Synchronization Explain how the following code can throw a ConcurrentModificationException. (0.5%) 1 class Question6 extends Thread { 2 private static Set<Integer> hashset = 3 Collections.synchronizedSet(new HashSet<Integer>()); 4 private static Lock lock = new ReentrantLock(); 5 public Question6(int num) { 6 hashset.add(num); 7 } 8 public void run() { 9 lock.lock(); 10 try { 11 Iterator<Integer> iterator = hashset.iterator(); 12 while (iterator.hasnext()) { 13 System.out.print(iterator.next() + " "); 14 } 15 } finally { 16 lock.unlock(); 17 } 18 } 19 } While iterating through the hashset on lines 12-14, if another thread gets to line 6, a ConcurrentModificationException will be thrown. Iterating in Java is fail-fast, meaning that you cannot modify a data structure while another thread is iterating over it. 3/7

7. Locks In the following code, assume a thread calls the method foo(). Answer the questions that follow the code. (0.25% + 0.25% + 0.25% + 0.25%) 1 import java.util.concurrent.locks.lock; 2 import java.util.concurrent.locks.reentrantlock; 3 public class Question7 { 4 private Lock lock = new ReentrantLock(); 5 public void foo() { 6 try { 7 lock.lock(); 8 System.out.println("foo 1"); 9 bar(); 10 System.out.println("foo 2"); 11 } finally { 12 lock.unlock(); 13 } 14 } 15 16 public void bar() { 17 try { 18 lock.lock(); 19 System.out.println("bar"); 20 } finally { 21 lock.unlock(); 22 } 23 } 24 25 public static void main(string [] args) { 26 Question7 q7 = new Question7(); 27 q7.foo(); 28 } 29 } a. Does foo 1 get printed? Yes No b. Does bar get printed? Yes No c. Does foo 2 get printed? Yes No d. If yes, explain why foo 2 is printed. If not, what happens? The lock being used on line 4 is a ReentrantLock, meaning that you do not have to get the lock again to get into another critical section of code managed by that lock. That means that getting the lock on line 18 and releasing the lock on line 21 will not occur if the method bar() is called from within the method foo(). 4/7

8. Multi-Threaded Programming Look at the following code then answer the questions below. (0.5% + 0.5%) 1 import java.util.concurrent.locks.lock; 2 import java.util.concurrent.locks.reentrantlock; 3 4 public class Question8 { 5 private Lock lock = new ReentrantLock(); 6 public synchronized void foo() { 7 try { 8 lock.lock(); 9 System.out.println("foo"); 10 } finally { 11 lock.unlock(); 12 } 13 } 14 public void bar() { 15 try { 16 lock.lock(); 17 synchronized(this) { 18 System.out.println("bar"); 19 } 20 } finally { 21 lock.unlock(); 22 } 23 } 24 } a. Is there a chance of deadlock? Yes No b. If yes, explain how? If no, what are all the possible outputs? Deadlock can occur if one thread calls foo and gets the lock on the instance of Question8, then it gets switched out of the CPU. Another thread comes in and gets the lock declared in line 5 on the same instance of Question8. The second thread will not be able to get into the synchronized block of code on line 17, and the first thread will not be able to get the lock on line 8. This causes circular waiting, which will be deadlock. 9. Conditions There are two ways to wake up a thread that is waiting on a condition signal() and signalall(). Since we don t have control over the order threads are switched into the CPU from the Ready state, why would we ever call signal() instead of signalall()? (0.5%) The signal() method can be used to wake up just one thread that is waiting on a condition. We could make it wake up the thread that has been waiting on the condition the longest if the fairness policy is set to true. With the fairness policy set to false, a random thread will be woken up, which will be the same as calling signalall() and letting the JVM decide which thread to put into the CPU next. 5/7

10. Databases and SQL Answer the following questions concerning the database below. Here is the Book table. Here is the User table. Here is the CheckedOut table. a. Write the SQL code to represent jenny checking out the book Happy Birthday, Bad Kitty. (0.5%) INSERT INTO CheckedOut (bookid, userid, numcheckedout) VALUES (4, 4, 1); OR INSERT INTO CheckedOut (bookid, userid, numcheckedout) VALUES ( SELECT bookid FROM Book WHERE title= Happy Birthday, Bad Kitty, SELECT userid FROM User WHERE username= jenny, 1); b. Draw the table that is returned from the following query after the SQL statement from part a has executed. (0.5%) SELECT b.title, co.numcheckedout FROM Book b, CheckedOut co WHERE b.bookid=co.bookid; title numcheckedout Balto of the Blue Dawn 1 Balto of the Blue Dawn 1 Tonight on the Titanic 2 Afternoon on the Amazon 1 Happy Birthday, Bad Kitty 1 6/7

Extra Credit Questions Extra credit is applied after the curve so does not affect other students. Extra Credit For the final project, we required weekly meetings with your assigned CP. (0.25%) Did you think these meetings were beneficial? Yes No Please explain. 105 (81.4%) yes 24 (18.6%) no Extra Credit This is the first semester we have included web development in the course. (0.25%) Do you think this was a positive change? Yes No How do you think we can improve on this change? 125 (96.9%) yes 4 (3.1%) no 7/7