These questions are based on the Miranda and Java units and are in
no particular order. DISCLAIMER: These are only questions I've
provided to guide your study, so while the topics are all relevant,
they do not necessarily reflect the kinds of questions that will be on
the exam in any way.
- Name one advantage and one disadvantage of dynamic typing. ...of
static typing.
- In language X, you are not required to specify variable types or
function return types. What can you conclude about typing in this
language and why?
- What can you do in a weakly typed language that is impossible in a
strongly typed language?
- Identify something you can do in a pure functional language that you
can't do in an imperative language.
- Identify something you can do in an imperative language that you can't
do in a pure functional language.
- Suppose Mocha is a new version of Java with first class methods. What
could you do with Mocha that you couldn't do (very easily, at least)
in Java?
- Write a Miranda function that can be defined using pattern-matching or
guards using both styles.
- Is it possible for a language that supports higher order functions to
not support currying?
- Is it possible for a language that has eager (not lazy) evaluation to
support higher order functions?
- Write an expression that would be evaluated differently by languages
with and without lazy evaluation.
- Suppose Miranda-- is just like Miranda, except that it's missing list
comprehensions. Are there functions you could write in Miranda that
you couldn't write in Miranda-- due to this limitation?
- What are the advantages of lazy evaluation?
- How do normal and applicative order rewriting differ?
- Shallow copy was a potential problem with C++ classes. Given Java's
different memory handling, is shallow copy a potential problem in
Java?
- How does Java treat primitive and class types differently?
How...similarly?
- Why does Java treat primitive and class types differently?
- Argue why it is a bad idea to treat primitive and class types
differently.
- Are constructors in Java dispatched statically or dynamically?
- Are class methods dispatched statically or dynamically?
- Suppose you have member data in a class for which you want to enforce
the following access restrictions:
- Client code can read and write the value.
- Subclass methods can read the value but not write it.
- This class's methods can read and write it.
Describe in words how you would implement this or explain why it is
impossible.
Now consider these restrictions...
- Client code can read the value but not write it.
- Subclass methods can read and write it.
- This class's methods can read and write it.
Describe in words how you would implement this or explain why it is
impossible.
- Is it possible for a method to be both an override and an overload at
the same time?
- Explain how you would determine whether a method overloads another
method. ...whether a method overrides another method.
- What is the difference between an interface and an abstract class?