Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help me code the following in: JAVA! Please use many comments so I can un

ID: 3711181 • Letter: P

Question

Please help me code the following in: JAVA!

Please use many comments so I can understand.

Full points will be awarded, thanks in advance!

Here is the driver:

Final Section: Pass-By-Reference & Pass-By-Value Demo in the ClassDesignllDriver Class Look inside the driver class to find the passByReferenceDemo() function. Uncomment this function call in main Trace its execution by adding a debugging breakpoint in the gutter area of your text editor and starting your program in debug mode. On observing the execution of the demo code, answer the following questions... 1. 2. 3. What is the primary difference between passing a primitive to a method versus passing an object? When a primitive is passed to a method, does the scope of that primitive change (i.e., grow to include the called method)? What about when an object is passed to a method? How then would you describe the scope of an object that has been passed to a method? a. b. c. d. Sample Output a is :3 b is :java.awt.Dimension[width-0,height-0] a is :3 b is :java.awt.Dimension[width-1000,height--1000]

Explanation / Answer

a) Java primitive types are passed by value where as objects are passed by reference

b) When a primitive type is passed to a method, it is passed by value. So any changes made to the variable in the called method are not seen in the calling method. This is demonstrated in the output, the value of a=3 before and after method call.

c) When an object is passed, the object is passed by reference. Therefore changes made to the object in the called method are available in the calling method after the called method returns. This is demonstrated in the output, the value of b changes after the method call.

d) Scope of objects passed to a method is always global. Changes are preserved in the same object

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote