Professional Documents
Culture Documents
1. Inheritance – One of the problems with multiple inheritance in C++ can be seen in
the code below. Some people may argue that Java supports multiple inheritance since
it allows inheriting from multiple interfaces simultaneously. Explain how the
ambiguity problem shown in the C++ code below will not occur in Java. (1.0%)
1 #include <iostream>
2 using namespace std;
3 class Email_Reader {
4 public:
5 void send_email() {
6 cout << "Email sending email";
7 }
8 };
9 class Telephone {
10 public:
11 void send_email() {
12 cout << "Telephone sending email";
13 }
14 };
15 class IPhone : public Telephone, public Email_Reader {
16 };
17
18 void main() {
19 IPhone ip;
20 ip.send_email(); // this line is ambiguous
21 }
2. Garbage Collection – Why do you think the creators of Java didn’t make the garbage
collector preempt currently-executing threads? (0.5%)
<!‐‐ index.html ‐‐>
<html>
<head>
<title>Question 3</title>
</head>
<body>
<form name="myform" action="submit.jsp">
Name <input type="text" name="name" /><br />
School <input type="text" name="school" /><br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
<%‐‐ submit.jsp ‐‐>
<%@ page language="java" %>
<html>
<head>
<title>Question 3</title>
</head>
<body>
<script language="JavaScript">
document.write(document.myform.name.value);
document.write(document.myform.school.value);
</script>
</body>
</html>
4. JavaScript and AJAX – The third parameter to the open function on the
XMLHttpRequest object is a boolean value representing whether the request will
be made synchronously (false) or asynchronously (true). Why would a programmer
ever want to make a synchronous AJAX call? (1.0%)
6. Software Engineering – Give two reasons why pair programming with junior to
mid-range programmers could be more productive than two programmers working
independently. (0.25% + 0.25%)
Reason #1
Reason #2
IP – 156.87.146.27
IP – 1001 1100 0101 0111 1001 0010 0001 1011
Subnet Mask – 255.255.240.0
Subnet Mask – 1111 1111 1111 1111 1111 0000 0000 0000
Decimal
g. What are the first and last IP addresses that could be assigned to hosts in the
subnetwork? (0.25% + 0.25%)
First Assignable IP Address (in decimal, not binary)
1 import java.util.concurrent.locks.Lock;
2 import java.util.concurrent.locks.ReentrantLock;
3 public class Question9 {
4 private Lock l = new ReentrantLock();
5 public void a() {
6 try {
7 l.lock();
8 System.out.println("a");
9 } finally {
10 l.unlock();
11 }
12 }
13
14 public void b() {
15 try {
16 l.lock();
17 System.out.println("b1");
18 a();
19 System.out.println("b2");
20 } finally {
21 l.unlock();
22 }
23 }
24
25 public static void main(String [] args) {
26 Question9 q9 = new Question9();
27 q9.a();
28 q9.b();
29 }
30 }
b. If the variable l was not reentrant, what would the output of the code be? (0.5%)
1 import java.util.concurrent.locks.Lock;
2 import java.util.concurrent.locks.ReentrantLock;
3
4 public class Question10 extends Thread {
5 private int num;
6 private Lock lock = new ReentrantLock();
7
8 public Question10(int num) {
9 this.num = num;
10 }
11 public void bar() {
12 lock.lock();
13 try {
14 System.out.println(num + "bar 1");
15 System.out.println(num + "bar 2");
16 } finally {
17 lock.unlock();
18 }
19 }
20 public void run() {
21 System.out.println(num + "foo");
22 bar();
23 }
24 public static void main(String [] args) {
25 for (int i=0; i < 100; i++) {
26 Question10 q10 = new Question10(i);
27 q10.start();
28 }
29 }
30 }
a. Give two rules concerning the output of the above program. In other words,
provide two statements that will always be true about the output. (0.5% + 0.5%)
Rule #1
Rule #2
b. Is the following portion of the output possible based on the above code? (0.5%)
15bar 1
14bar 1
15bar 2
14bar 2
a. Write the SQL code to get the departments that have been ranked at each
university. You will not return the rank. In other words, the following table
should be returned by the SELECT statement. It must be returned in the same
order as well. (0.5%)
12. Parallel Programming – With four cores in a single CPU computer, even with the
most optimized parallel algorithm, you won’t be able to get a four-time improvement
in the running time. Give two reasons why this is the case. (0.5% + 0.5%)
Reason #1
Reason #2
13. Distributed Computing – Parallel and distributed computing are both used to make a
program execute faster. What is the difference between parallel and distributed
computing? (0.5%)
Extra Credit (0.25%) – What was the most memorable lecture from this semester?
What made it memorable to you?
Extra Credit (0.25%) – Fill in the following table with one checkmark in each row
answering the following question. Do you think the amount of coverage of each topic
in the class was too little, just right, or too much?
Please explain.