PL Fall 2017 HW-1 solutions.pdf - Solution 1 1 From 4.2.3...

This preview shows page 1 - 2 out of 6 pages.

Solution 1: 1. From §4.2.3 of JLS8, the float and double values are stored with sign and magnitude along with positive and negative zeros. Apart from that, it can also store positive and negative infinities and a special Not-a-Number (NaN). 2. From §4.12.3 of JLS8, the 8 kinds of variables are i. class variable, ii. instance variable iii. array components iv. method parameters v. constructor parameters vi. lambda parameters vii. exception parameters viii.local variables 3. NO, From §4.12.5 of JLS8, the language specification does not guarantees the initialization of local variables to be zero. 4. From §5.1.3 of JLS8, a narrowing primitive conversion from signed integer to some other smaller integral type simply discards all but the n lowest order bits of the integer. Apart from the obvious loss of magnitude, the final sign may also differ. 5. From §7.2 of JLS8, it is not a must that the packages and compilation units be stored in files. For instance, it could be stored in a database. The requirement is that it provides a valid mechanism to export to the file-based implementations that obeys the restrictions of a file-based system. 6. From §8.1.3 of JLS8, an inner class is a nested class that is not explicitly or implicitly declared static. More concretely, an inner class could be a non-static member class, local class or an anonymous class. Interfaces are never inner classes.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture