Question: In Java please. Thanks Task 2: Understanding Programming Instructions: Answer each question below. Try to understand and explain the code. Do not put an IDE

In Java please. ThanksIn Java please. Thanks Task 2: Understanding Programming Instructions: Answer each question

Task 2: Understanding Programming Instructions: Answer each question below. Try to understand and explain the code. Do not put an IDE code screenshot. 1. Exercise 15: Suppose you have a class MyClass with one instance variablex. What will be printed by the following code segment? Myclass cl-new MyClass cl.3 MyClass c2 -cl c2.x4 System.out.println(cl.x)i Explain your answer 2. Exercile 16: Suppose a class has an instance variable x and a method with a local variable x Ifx is used in a calculation in the body of the method, which x is being referred to? a. b. Suppose you needed to add the local variable x to the instance variable x in the body of the method. How would you do so? 3. Exercise 17: The following method has a flaw (in fact, due to this flaw it will not compile). What is the flaw? void displayAbsxlint x) if (x >0) System.out-println (x) return System, out . printin {-x) return System, out . printin { "Done" ; 4. Exercise 18: Create a method max() that has two integer parameters x and y and returns the larger of x and y 5. Exercise 19: Create a method max() that has three integer parameters x, y, and z, and it returns the largest of the three. Do it two ways: once using an if-else-if ladder and once using nested if Statements. 6. Exercise 21: Find all the erors (f any) in the following class declaration: Class Myclass integer x3.0; boolean b false constructor MyClass (boolean b} { b-b; int doit() { int don'tDolt {} { return this

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!