Prof. Dr. A. Poetzsch-Heffter Dipl.-Inform. Markus Reitz
Technische Universität Kaiserslautern Fachbereich Informatik AG Softwaretechnik
Practice Sheet 4: Fortgeschrittene Aspekte objektorientierter Programmierung (SS 2008)
Date of Issue: 29. April 2008 Deadline: 05. Mai 2008 (until 10 a.m. as PDF via E-Mail)
Exercise 1 StooJas Extension
The Java subsetStooJasthat was presented in the lecture neither provides static methods nor static variables.
a) Extend the syntax as well as the semantics (static & dynamic) ofStooJasto support static methods. Please give a detailed explanation for the necessary adjustments.
b) Extend the syntax as well as the semantics (static & dynamic) ofStooJasto support static variables. Please give a detailed explanation for the necessary adjustments.
Exercise 2 Typing
a) Is the following code fragment a syntactical correct Java fragment? Please justify your answer.
. . .
i f ( c o n d i t i o n ) a=7 ; e l s e
a=a s L i s t ( 1 7 0 1 , 4 7 1 1 ) ; i f ( c o n d i t i o n )
a=a+7 ; e l s e
a . add ( 4 2 ) ;
S y s t e m . o u t . p r i n t l n ( a ) ; . . .
b) Is it possible to adapt the fragment just byaddingstatements, so a Java compiler is able to create the corresponding bytecode file? Please justify your answer.
c) Transform the fragment to a working JavaScript fragment, so the ouput is either14or1701,4711,42depending on the value of variablecondition.