Docsity

Exam 1 for Design and Implementation Programming Languages | CS 3360, Exams of Computer Science

Toggle sidebar
bg1
1
Spring 2007 (Thursday, March 1) Name:
CS 3360 โ€” Design and Implementation of Programming Languages
Exam 1
This test has 10 questions and pages numbered 1 through 7.
Reminders
This test is closed-notes and closed-book. However, you are allowed to bring 1 page (8.5 X 11) of notes (both
sides). Your notes must be your own, they must be hand written, and they must be turned in with your
test. You can also bring the AspectJ Quick Reference that summarizes AspectJ syntax. This test is to be
done individually, and you are not to exchange or share materials with other students during the test.
If you need more space, use the back of a page. Note when you do that on the front.
This test is timed. Your test will not be graded if you try to take more than the time allowed. Therefore,
before you begin, please take a moment to look over the entire test so that you can budget your time.
Clarity is important; if your writing or code is sloppy or hard to read, you will lose points. Correct syntax
also makes some difference.
There are 110 points all, including 10 points of extra credit.
1. (5 points) Name at least four different programming paradigms or categories and give an example
language for each.
2. (5 points) One of the design issues for object-oriented programming languages is support for multiple
inheritance. Name and explain the two main problems of multiple inheritance.
pf3
pf4
pf5

Partial preview of the text

Download Exam 1 for Design and Implementation Programming Languages | CS 3360 and more Exams Computer Science in PDF only on Docsity!

Spring 2007 (Thursday, March 1) Name:

CS 3360 โ€” Design and Implementation of Programming Languages

Exam 1

This test has 10 questions and pages numbered 1 through 7.

Reminders

This test is closed-notes and closed-book. However, you are allowed to bring 1 page (8.5 X 11) of notes (both sides). Your notes must be your own, they must be hand written, and they must be turned in with your test. You can also bring the AspectJ Quick Reference that summarizes AspectJ syntax. This test is to be done individually, and you are not to exchange or share materials with other students during the test. If you need more space, use the back of a page. Note when you do that on the front. This test is timed. Your test will not be graded if you try to take more than the time allowed. Therefore, before you begin, please take a moment to look over the entire test so that you can budget your time. Clarity is important; if your writing or code is sloppy or hard to read, you will lose points. Correct syntax also makes some difference. There are 110 points all, including 10 points of extra credit.

  1. (5 points) Name at least four different programming paradigms or categories and give an example language for each.
  2. (5 points) One of the design issues for object-oriented programming languages is support for multiple inheritance. Name and explain the two main problems of multiple inheritance.
  1. (total 15 points) This question is about bindings and typing.

(a) (5 points) List five different binding times and give an example of each.

(b) (2 points) When a programming language is called strongly typed?

(c) (8 points) Discuss the relative advantages and disadvantages of static storage binding and stack- dynamic storage binding, and also evaluate them regarding support for recursive calls and history- sensitive variables.

  1. (5 points) Define the following terms:
    • Join point
    • Pointcut
    • Advice
  1. (total 15 points) Consider the following context free grammar describing the syntax of binary numbers.

-> -> | -> 0 | 1

(a) (10 points) Define an attribute grammar that also gives the corresponding decimal numbers. That is, introduce an integer-valued attribute, say value, for the start symbol whose value should be set to the decimal value of the binary number.

(b) (2 points) For each attribute that you introduced for (a), indicate whether it is a synthesized or inherited attribute.

(c) (3 points) Extend your attribute grammar to permit only binary numbers that are multiples of 5.

  1. (5 points) Consider the following Java-like code. What value will be printed when static and dynamic scoping rules are used, respectively?

class ScopingRule { static int x = 200; static void print(int y) { System.out.println(x + y); } public static void main(String[] args) { int x = 100; print(x); } }

  1. (5 points) Aspect-oriented programming addresses the problem of crosscutting concerns. What are crosscutting concerns and what are the two main problems of crosscutting concerns?
  1. (10 points extra credit) Reconsider the class MethodCall of Problem 9. Write an aspect to make sure that the constructor is invoked with valid arguments. In particular, your aspect should enforce the following two constraints:
    • If the given method, meth, is an instance (i.e., non-static) method, the argument receiver should not be null.
    • The number of elements of the argument args should be equal to the number of parameters of the given method, meth.

If a constructor invocation doesnโ€™t satisfy the above constraints, the invocation should throw an IllegalArgumentException. You may assume that the class Method defines the following two meth- ods:

/** Returns true if this is a static method. */ public boolean isStatic();

/** Returns the formal parameter types, in declaration order, of this method.

  • Returns an empty array if this method takes no parameters. */ public Class[] getParameterTypes();