EBU6042 Paper A ‐ SOLUTIONS 2016/17
Question 1
a) The questions below refer to JavaScript and the DOM:
[9 marks]

EBU6042作业代写、Java编程作业调试、代写JAVA语言作业、代做DOM留学生作业
i) Indicate what the DOM abbreviation stands for and name THREE examples of objects found in
the DOM.
(4 marks)
ii) Consider the JavaScript code fragment in Figure 1 and fill in the THREE gaps in the sentences
below; you are only required to write down what the blanks marked 1 to 3 correspond to.
Figure 1
With regards to the code in Figure 1, if the user enters a response and clicks the OK button, then
the value of num will be _____1_____. If instead the user enters a response and clicks the Cancel
button, the value of num will be _____2_____. If the user clicks the OK button without entering
a response, then the value of num will be _____3_____.
(3 marks)
iii) Briefly describe the concept of event handler and indicate a typical use of onSubmit in a
webpage.
(2 marks)
Do not write in
this column
i) 4/9
DOM = Document Object Model [1 mark]
THREE examples of objects in the DOM: [3*1 mark: 3 correctly identified objects]
window, location, checkbox, submit, reset, button, radio, text
ii) 3/9
1. whatever value the user entered [1 mark]
2. Null [1 mark]
3. an empty string [1 mark]
iii) 2/9
Event handler: this is a command that JavaScript uses to deal with actions performed
by the user while visiting a webpage. [1 mark]
onSubmit does form validation using JavaScript, when the user submits an HTML
form. OR onSubmit triggers a function to run when a form is submitted. [1 mark]
9
marks

num = prompt("Please enter a positive number: ", "");
EBU6042 Paper A‐ SOLUTIONS 2016/17
b) Consider the HTML code shown in Figure 2 and answer the questions below:
[16 marks]
i) Assume that the code in Figure 2 is stored in file riverBusPlanner_home.html. Sketch how
the contents of this file would be displayed by a web browser. The webpage is for a company that
runs a river bus service, which allows people to travel by boat along the River Thames in London.
(8 marks)
ii) Write the code for the JavaScript function processInit() that is activated by clicking on the
Planner button, such that the following is checked:
1. That the user has filled in the email address and that it contains a ‘@’ sign in a position other
than at the start; if that field is empty or does not include a ‘@’ sign, then an alert box should
be generated with an appropriate message.
2. That the start and end river bus stops are different; if they are the same, an alert box should
be generated with an appropriate message.
If the above two checks are satisfied, then the webpage riverBusPlanner_journeys.html
is loaded. Note: It is not necessary to know the contents of this second HTML page.
Your answer must also state where you would need to add this JavaScript function, in the HTML
code describing the webpage in Figure 2.
(8 marks)
Figure 2
<HTML>
<HEAD> <TITLE>Thames River Bus</TITLE> </HEAD>
<BODY>
<FORM NAME="formInit">
<H3>Thames River Bus Service: Journey Planner</H3>
Email address: <INPUT TYPE="text" NAME="emailAddress">
<P><B>Time of day:</B>
<INPUT TYPE="radio" NAME="time" VALUE="peak">Peak time
<INPUT TYPE="radio" NAME="time" VALUE="offpeak">Off-peak time
<P><B>Choose a river bus stop for the start and end of your journey:</B></P>
Start&nbsp;
<SELECT NAME="start">
<OPTION SELECTED>Canary Wharf</OPTION>
<OPTION>Greenland</OPTION>
<OPTION>Masthouse Terrace</OPTION>
</SELECT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
End&nbsp;
<SELECT NAME="end">
<OPTION SELECTED>Masthouse Terrace</OPTION>
<OPTION>Greenland</OPTION>
<OPTION>Canary Wharf</OPTION>
</SELECT>
<P><B>Press Planner to look at available route options:</B>
<P><INPUT TYPE="button" NAME="plan" VALUE="Planner" onClick="processInit()">
</FORM>
</BODY>
</HTML>
Do not write in
this column
i) 8/16
[1 mark]: page title and header are both shown;
[1 mark]: email address textbox is shown, preceded by the appropriate label;
[2 marks]: 2 radio buttons on the same line, each followed by the appropriate label;
[2 marks]: 2 menus shown on the same line, each preceded by the correct label,
and each with the appropriate default option shown;
[1 mark]: Planner button is shown;
[1 mark]: the sketched page has a sensible overall layout.
ii) 8/16
function processInit() {
firstForm = document.forms["formInit"];
if (formInit.emailAddress.value == "")
alert("Please fill in your email address!");
else if (formInit.emailAddress.value.indexOf('@')< 1)
alert("Invalid email address!");
else if (formInit.start.value == formInit.end.value)
alert("Your origin and destination stops must be different!");
else window.location.href="riverBusPlanner_journeys.html";
}
EBU6042?Paper?A?‐?SOLUTIONS 2016/17
Page?4?of?17
Do not write in
this column
[1 mark: correct function declaration]
[2 marks: 4 checking conditions ? 1) start-end check, 2) empty email, 3) if @ sign
exists, 4) @ sign not first character; the last two could be 1 or 2 conditions]
[3*1 marks: 3 alert boxes with sensible messages]
[1 mark: an attempt at redirection]
The function processInit() should be placed in the <HEAD> section of the HTML
page [1 mark].
16
marks
Question marking: 9 16 25
Question 2
a) Consider the statements below about JSPs, servlets and sessions. Identify the statements that are
FALSE and correct them.
[7 marks]
1. A session object is created the first time that a browser requests a servlet or JSP from a website.
2. The current session object is available only to servlets.
3. A servlet communicates with the servlet engine in the web server via a request and response
object of the HttpServletRequest and HttpServletResponse classes respectively, in the
form of streams.
4. JSPs use delimiters such as <% and %> to include Java code that the JSP engine in the web server
then converts directly to HTML code.
5. In the Tomcat web server, the web.xml file has the tag <servlet-engine> that identifies the
name and the type of the servlet engine used by the web server.
Do not write in
this column
FALSE statements: 2, 4, 5 [3*1 mark]
Correction of FALSE statements:
2. The current session object is available to both servlets and JSPs. [1 mark]
4. JSPs use delimiters such as <% and %> to include Java code that the JSP engine in
the web server then converts to a servlet. [1 mark]
5. In the Tomcat web server, the web.xml file has the tag <servlet-name> that
identifies the class name of the serlvet or its alias name. [2 marks]
7
marks
b) Consider the webpage shown in Figure 3 and answer the questions below:
[15 marks]
i) Assume that a user’s personal data is sent to a JSP called StoreData.jsp, once the Submit
button is clicked. Write the code for a JavaBean called UserData that will store the user’s details
on the server side; you can assume that the JavaBean is stored in a package called user, and that
the user data parameters are called name and age.
(10 marks)
ii) Write the code for the JSP called StoreData.jsp that uses the JavaBean you wrote in part i)
to collect the user’s data. This JSP then loads another JSP called DisplayData.jsp, upon
clicking Continue.
Note: You are not required to write the code for DisplayData.jsp.
(5 marks)
Figure 3
Do not write in
this column
i) 10/15
package user; [1 mark]
import java.io.*;
public class UserData implements Serializable { [2 marks]
private String name; [1 mark]
private int age; [1 mark]
public UserData() { } [1 mark]
public void setName(String value) { name = value; } [1 mark]
public void setAge(int value) { age = value; } [1 mark]
public String getName() { return name; } [1 mark]
public int getAge() { return age; } [1 mark]
}

Do not write in
this column
ii) 5/15
<jsp:useBean id="usr" class="user.UserData" scope="session"/>
[2 marks]
<jsp:setProperty name="usr" property="*"/> [1 mark]
<HTML>
<BODY>
<A HREF="DisplayData.jsp">Continue</A> [1 mark]
</BODY>
</HTML>
[1 mark: sensible overall structure]
15
marks
c) Servlets have THREE lifecycle methods.
[3 marks]
i) Describe what the init() method does and when it is used.
(2 marks)
ii) Name the other TWO servlet lifecycle methods.
(1 mark)
Do not write in
this column
i) 2/3
The init() method is used by the container to initialise the servlet; it is invoked
only once in the lifecycle of the servlet. [2 marks]
ii) 1/3
Other TWO servlet lifecycle methods: service() and destroy() [2*0.5 mark]
3
marks
Question marking: 7 15 3 25
Question 3
a) The questions below refer to threads:
[12 marks]
i) What is a daemon thread? Which method in Thread is used to make a thread a daemon?
(2 marks)
ii) Write the code for a thread called PrintThread that accepts a String as a parameter in its
constructor. When running, PrintThread should print its String to the screen.
(4 marks)
iii) Write a main() method that constructs 100 new instances of PrintThread and then starts them
executing concurrently.
(4 marks)
iv) Will the output of main() be deterministic, i.e. will the console output always be the same?
Justify your answer.
(2 marks)
Do not write in
this column
i) 2/12
A daemon thread is a thread that is automatically terminated when its parent dies.
[1 mark]
The method is setDaemon(true). [1 mark]
ii) Note: The student can implement the thread by either extending the Thread class 4/12
OR by implementing Runnable.
public class PrintThread extends Thread { [1 mark]
private String toPrint = null;
public PrintThread(String toPrint) { [1 mark]
this.toPrint=toPrint;
}
public void run() { [1 mark]
System.out.println(toPrint); [1 mark]
}
} // End of class
Do not write in
this column
iii) 4/12
public static void main(String[] args) { [1 mark]
for (int i=0; i<10; i++) { [1 mark]
PrintThread thread = new PrintThread("Thread-"+i); [1 mark]
thread.start(); [1 mark]
OR (alternative approach – also worth 2 marks)
Note: Please ensure the approach matches the student’s answer to part ii).
MyRunnable runnable = new MyRunnable("Thread-" + i);
Thread thread = new Thread(runnable);
thread.start();
}
}
iv) 2/12
The output will be non-deterministic. [1 mark]
The order is based on when the threads get scheduled, which may change each time
the code is executed. [1 mark]
12
marks
b) The code in Figure 4 is a simplified form of a read-write lock.
[9 marks]
Figure 4
i) Explain the difference between a simple lock and a read-write lock. Why might a read-write lock
achieve better performance?
(2 marks)
ii) Explain the use of wait() in general, and its use in method lockWrite() of Figure 4 in
particular.
(4 marks)
iii) Explain the use of notify() and notifyAll() in general. Also explain how notifyAll()
is used in method unlockRead() of Figure 4 in particular.
(3 marks)
Do not write in
this column
i) 2/9
A read-write lock does not allow multiple threads to read or write data at the same
time. [1 mark]
However, concurrent reads are usually acceptable, so this is not a good idea. [1 mark]
public class ReadWriteLock {
private int readers = 0;
private int writers = 0;
private int writeRequests = 0;
public synchronized void lockRead() throws InterruptedException {
while(writers > 0 || writeRequests > 0) { wait(); }
readers++;
}
public synchronized void unlockRead() {
readers--;
notifyAll();
}
public synchronized void lockWrite() throws InterruptedException {
writeRequests++;
while(readers > 0 || writers > 0) { wait(); }
writeRequests--;
writers++;
}
public synchronized void unlockWrite() throws InterruptedException {
writers--;
notifyAll();
}
}
EBU6042?Paper?A?‐?SOLUTIONS 2016/17
Page?11?of?17
Do not write in
this column
ii) 4/9
wait() tells the calling thread to give up the monitor and go to sleep until some
other thread enters the same monitor and calls notify(). [2 marks]
If there are any readers or writers wanting access to the lock, the thread calling this
method (which wants to do a write) is put in the “wait set”. [2 marks]
iii) 3/9
notify() wakes up an arbitrary thread that called wait() on the same object.
[1 mark]
notifyAll() wakes up all the threads that have called wait() in no particular
order, so that they can try to acquire the monitor. [1 mark]
In unlockRead() there is one less thread wanting read access and notifyAll()
tells all the threads in the “wait set”; these could be threads wanting to do reads or
writes. [1 mark]
9
marks
c) The questions below refer to sockets and threads:
[4 marks]
i) Write the Java code to create a socket that connects to a server with the IP address 10.0.0.1. It
should connect to the server on port 80.
(2 marks)
ii) Write the Java code to create a server-side listening socket. It should listen on port 80.
(1 mark)
iii) Why is it important for a web server to be built using multiple threads?
(1 mark)
Do not write in
this column
i) 2/4
Socket s = new Socket("10.0.0.1", 80);
[1 mark: IP and port; 1 mark: socket]
ii) 1/4
ServerSocket ss = new ServerSocket(80); [1 mark]
Do not write in
this column
iii) 1/4
A web server must deal with multiple concurrent users. Thus, each user must be
served in its own thread. [1 mark]
4
marks
Question marking: 12 9 4 25
Question 4
a) Write a simple webpage that looks like the one in Figure 5. Ensure that you put all HTML elements
in, so that it could be correctly loaded by a web browser.
[4 marks]
Figure 5
Do not write in
this column
Note: Marks are allocated for opening and closing the HTML tags correctly.
If a tag is opened correctly, but not closed correctly, please allocate half marks.
<html> [0.5 mark]
<body> [0.5 mark]
<p>Here is a list</p> [1 mark]
Note: Other tags are allowed, e.g. <big>, <em>, <i>.
<ul> [1 mark]
<li>Bread</li> [1 mark]
<li>Crisps</li>
<li>Meat</li>
</ul>
</body>
</html>
4
marks
b) The following questions relate to Java’s Remote Method Invocation (RMI).
[16 marks]
i) Serializable is a marker interface. What is a marker interface? What does it mean when you
write a class that implements Serializable?
(2 marks)
ii) Explain the concept of skeletons and stubs in RMI. Include the following in your answer:
? Does each one operate on the client or on the server?
? What are the steps they take when a Remote Method Invocation is executed?
(8 marks)
Here is a list:
Bread
Crisps
Meat
iii) Write a remote interface for a server that adds two numbers together. The remote interface should
contain a single method call add(). The interface should be called AddServerInterface.
(4 marks)
iv) Describe what the client and server objects use the rmiregistry for in RMI. Note: You do not
need to write code.
(2 marks)
Do not write in
this column
i) 2/16
A marker interface is one that does not contain any methods; it just signals
something. [1 mark]
Implementing Serializable indicates that a class can be serialized by Java.
[1 mark]
ii) 8/16
SKELETON
A class that sits on the server side. [1 mark]
Receives remote method calls and parameters. [1 mark]
Invokes the method locally. [1 mark]
Sends the return value back to the client. [1 mark]
STUB
A class that sits on the client side. [1 mark]
Presents the same remote interface as the server object. [1 mark]
Accepts any method invocations and forwards them to the server. [1 mark]
Receives any return results. [1 mark]
iii) 4/16
public interface AddServerInterface [1 mark]
extends Remote { [1 mark]
public int add(int a, int b) [1 mark]
throws RemoteException; [1 mark]
}

Do not write in
this column
iv) 2/16
The rmiregistry is used by servers to register remote objects. [1 mark]
The rmiregistry is used by clients to lookup remote objects. [1 mark]
16
marks
c) The following questions are based on the HTTP response in Figure 6.
[5 marks]
Figure 6
i) What is the purpose of the status code in an HTTP response? What is the status code of the
response shown in Figure 6?
(2 marks)
ii) What type of content is in the payload of the HTTP response in Figure 6?
(1 mark)
iii) Will a browser cache this HTTP response? Explain your answer.
(2 marks)
Do not write in
this column
i) 2/5
The status code tells the client what is the status of the message. [1 mark]
The status code in the response is 200. [1 mark]
ii) 1/5
The content in this response is HTML. [1 mark]
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Date: Sat, 13 Mar 2016 11:37:51 GMT
Server: Apache
Connection: close
Cache-Control: no-cache
Content-Type: text/html; charset=UTF-8
Last-Modified: Sat, 15 Jan 2016 09:50:17 GMT
Content-Encoding: gzip
Do not write in
this column
iii) 2/5
The browser will not cache the content [1 mark], because the Cache-Control
header is set to no-cache [1 mark].
5
marks
Question marking: 4 16 5 25

因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:99515681@qq.com

微信:codinghelp

转载于:https://www.cnblogs.com/javapythonc/p/10311115.html

EBU6042 Paper A ‐ SOLUTIONS相关推荐

  1. signature=0e42fe6b348b65f88748ba8ecefece12,Low power BIST

    摘要: In the last years designers have mainly concentrated on low power consumption in mobile computin ...

  2. 笑死:Welcome to Skip Thompson's Homepage

    Welcome to Skip Thompson's Homepage 有一位退休的姓"汤姆森"的老教授,他老人家的个人主页名字如上,直接翻译过来就是"欢迎跳过(略过,忽 ...

  3. 纸浆模塑包装(MPP)行业调研报告 - 市场现状分析与发展前景预测

    纸浆模塑包装(MPP)可以模塑成相关产品的形状,例如酒,蛋,以提供更好的安全包装. 纸浆模塑包装(MPP)市场的企业竞争态势 该报告涉及的主要国际市场参与者有FiberCel.Taiwan Pulp ...

  4. 2022.11.20 学习周报

    文章目录 摘要 论文阅读 1.题目 2.摘要 3.网络结构 3.1 网络示意图 3.2 网络特点 4.问题的提出 5.正则化带有LSTM单元的RNNs 5.1 LSTM单元 5.2 具有 Dropou ...

  5. CVPR 2011 全部论文标题和摘要

    CVPR 2011 Tian, Yuandong; Narasimhan, Srinivasa G.; , ■Rectification and 3D reconstruction of curved ...

  6. Paper:《NÜWA: Visual Synthesis Pre-training for Neural visUal World creAtion,女娲:用于神经视觉世界创造的视觉》翻译与解读

    Paper:<NÜWA: Visual Synthesis Pre-training for Neural visUal World creAtion,女娲:用于神经视觉世界创造的视觉>翻 ...

  7. Paper:《A Unified Approach to Interpreting Model Predictions—解释模型预测的统一方法》论文解读与翻译

    Paper:<A Unified Approach to Interpreting Model  Predictions-解释模型预测的统一方法>论文解读与翻译 导读:2017年11月25 ...

  8. Paper:《Multimodal Machine Learning: A Survey and Taxonomy,多模态机器学习:综述与分类》翻译与解读

    Paper:<Multimodal Machine Learning: A Survey and Taxonomy,多模态机器学习:综述与分类>翻译与解读 目录 <Multimoda ...

  9. Paper:《Hidden Technical Debt in Machine Learning Systems—机器学习系统中隐藏的技术债》翻译与解读

    Paper:<Hidden Technical Debt in Machine Learning Systems-机器学习系统中隐藏的技术债>翻译与解读 导读:机器学习系统中,隐藏多少技术 ...

最新文章

  1. SAP Promotion Managementfor Retail (SAP PMR)
  2. spring remoting源码分析--Hessian分析
  3. 吴恩达深度学习笔记5-Course2-Week1【深度学习的实用层面】
  4. 汉澳sinox2014x64server已经能够下载
  5. 剑指offer55-I-二叉树的深度
  6. kubectl命令大全
  7. android悬浮窗工具,Android悬浮窗实例
  8. Oracle10g下载地址--多平台下的32位和64位
  9. 打开Hololens自动相机,和live stream
  10. 正负数据如何归一化_数据归一化方法大全
  11. QT小项目练手——用QTimer做一个倒计时程序
  12. Linux 简单查看网卡实时网速
  13. EXCEL表格-整体加密和内容加密
  14. 使用aspose.words将Word转为PDF
  15. 老男孩python2020年31期学习记录贴
  16. 数据结构:关于时间复杂度的例题计算
  17. 电脑硬件及电脑配置知识大全
  18. 人生不是故事,人生是世故,摸爬滚打才不会辜负功名尘土
  19. Java 机内码 String 转化
  20. FDN, SDN, ADN, BDN, MSISDN,LND, EXT1,EXT2, EXT3 代表的意义和作用

热门文章

  1. c++ clr编译dll在c#调用时出现“试图加载不正确的格式”“找不到dll”错误的解决...
  2. 脉讯发布“社群搜索工具” 助企业精准洞察消费者需求
  3. 自己封装JSTL 自定义标签
  4. 微信小程序记账应用实例课程(完结)——对接服务端账目CRUD
  5. openvn客户端连接配置(ubnutu)
  6. 最强杀毒软件NOD32免费升级ID(保持最新)
  7. ISE include 头文件错误的解决办法
  8. C++创建二维数组和矩阵
  9. C++实现Hash表
  10. 验证和训练loss和acc多种情况分析