A library defines a generic class Foo in a Java-like language. A users program declares a class
Fantastic news! We've Found the answer you've been seeking!
Question:
A library defines a generic class Foo in a Java-like language. A user’s program declares a class C and subclasses it as class D, creating variables fc and fd of types Foo and Foo respectively. (i) Construct a declaration of Foo along with a program of the above form containing the assignment fc=fd which, if this statement were legal, would be the cause of a later run-time error when executed. (ii) How might the language syntax be changed to optionally express that the above assignment is to be allowed, indicating any compensating restrictions required for the declaration of Foo or fc to avoid run-time errors. (iii) How do Java arrays of type T[] fit in with your answer to Part (c)(i)?
Related Book For
Microeconomics An Intuitive Approach with Calculus
ISBN: 978-0538453257
1st edition
Authors: Thomas Nechyba
Posted Date: