Question: Consider a language that allows nested functions. Use the following stack contents to answer the following true/false questions. A) sub4 is nested/defined in sub1. TRUE/FALSE.

  1. Consider a language that allows nested functions. Use the following stack contents to answer the following true/false questions. A) sub4 is nested/defined in sub1. TRUE/FALSE. Justify your answer.

B) sub2 has access to variables in main. TRUE/FALSE. Justify your answer.

  1. (20 points) Study the Java BNF to ensure that you understand the notational conventions used in that BNF. Now, use those notational conventions to write a concise rule to capture the following syntax. That is, write BNF rules that could be added to the given BNF

  1. With respect to Java, identify the strings that match the given grammar rule.

Java Grammar Rule

Strings

Yes/No

0x8

x0

0x34eE

FE00

.55

55.

0.0

0.0d

.E22

1.0+E10

1.0E+2f

1.0e2f

1.0e00f

  1. (20 points) With respect to the Java grammar, answer the following questions:

    • Determine the shortest possible .

      1. You do not need to provide a derivation. Just provide the final string.

    • Do import statements have to appear at the top of a Java program? Justify your answer using the grammar.

  1. (10 points) Use the virtual machine instructions given in Chapter 3. Write the operational semantic definition of Javas do-while.

  1. (10 points) Compute the weakest precondition for:

{ fill this in }

if (x > y) y = 2 * x + 1; else y = 3 * x - 1; { y > 3 }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!