Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please solve 1 and 2. i have provided the java code as well. Numbered items all have approximately equal weight. There are extra points built

image text in transcribedplease solve 1 and 2. i have provided the java code as well.
image text in transcribed
Numbered items all have approximately equal weight. There are extra points built into the scoring system. Show all work! Answers without adequate support will receive significantly reduced credit. Partial credit is available on most items. 1. Refer to the Java code for MyClass 1, My Class2, and MyDriver in the Supplement. When I ran this program, the output was as follows: ----GRASP exec: java MyDriver Value of a - 57 Value of a = 42 L ----GRASP: operation complete. a. Explain this output. b. What is meant by aliasing? How does this code illustrate this phenomenon? c. Briefly discuss the impact of aliasing on readability, writability, and reliability? 2. Consider the following context free grammar for expressions with the "weird" operations ? and $: ? | $ () | abc a. Use the expression "a? b $c" to show that this grammar is ambiguous. b. Now write an unambiguous grammar for expressions in which (1) parenthesized expressions take precedence over any other expression, (2) the operation S takes precedence over ?, and (3) $ is left associative and ? is right associative. (HINT: You may need to use some additional non-terminals.) Item 1 uses the following Java code: class Myclassi { private int a; public void setA (int value) (a = value; } public int getA {return a; } class MyClass2 { private MyClassi myobjecti - new MyClass(); public void setMyObjectIA (int value) { myObjecti.setA (value); public MyClassi getMyObjectif return myObjectl; public void myMethod (Myclass1 anobject) { anObject.setA (42); class MyDriver { public static void main (String[] args) { MyClass2 myObject2 = new MyClass2(); myObject2.setMyObject1A (57); System.out.println ("Value of a = " + myObject2.getMyObject1().getA()); MyClassl myObject = myObject2.getMyObject1(); myObject2.myMethod (myObject); System.out.println("Value of a = " + myObject2.getMyObject1().getA())

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications Dexa 2022 Workshops 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 In Computer And Information Science 33

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Alfred Taudes ,Atif Mashkoor ,Johannes Sametinger ,Jorge Martinez-Gil ,Florian Sobieczky ,Lukas Fischer ,Rudolf Ramler ,Maqbool Khan ,Gerald Czech

1st Edition

ISBN: 3031143426, 978-3031143427

More Books

Students also viewed these Databases questions