Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The class Demo is defined as follows: class Demo { private int vall; private int val2; public void setValues(int num1, int num2) { val1

image text in transcribed image text in transcribed 

The class Demo is defined as follows: class Demo { private int vall; private int val2; public void setValues(int num1, int num2) { val1 = num1; val2 = num2; } public int getValue1() { return (val1); } public int getValue2() { return (val2); } public int getAverage() { return( (valu1 + valu2) / 2); } // the first data member // the second data member Define the class Exercise 01 with the following methods: A. Static method add Demo () that receives as arguments two objects of the class Demo and then builds and returns another object of the class Demo such that the value of each of its member variables is the sum of the values of the corresponding member variables of its arguments. B. Static method incrDemo2 that receives as argument an object of the class Demo and increments the value of each of its member variables by 5. c. method main does the following: 1. Declare object item of the class Demo. 2. Read the values for the instance variables of object item, and set their values. 3. Compute the average of the values of the instance variables of object item and print it. 4. Declare object obj1 and set its instance variables to 5 and 7 respectively. 5. Declare object obj2 and set its instance variables to 14 and 9 respectively. 6. Create a third object named objR such that the value of each of its instance variables is the sum of the values of the corresponding instance variables of objects obj1 and obj2 by calling addDemo (). Activate Windows Go to Settings to activate Windows. 7. Increment the value of each instance variable of object obj1 by 5 by calling incrDemo(). 8. Print the values of the instance variables of the objects objR and obj1.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

class Demo private int val1 private int val2 public void setValuesint num1 int num2 val1 num1 val2 n... 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

Java Software Structures Designing And Using Data Structures

Authors: John Lewis, Joe Chase

4th Edition

0133250121, 978-0133250121

More Books

Students also viewed these Programming questions

Question

What are the challenges associated with tunneling in urban areas?

Answered: 1 week ago

Question

What are the main differences between rigid and flexible pavements?

Answered: 1 week ago

Question

What is the purpose of a retaining wall, and how is it designed?

Answered: 1 week ago

Question

How do you determine the load-bearing capacity of a soil?

Answered: 1 week ago

Question

what is Edward Lemieux effect / Anomeric effect ?

Answered: 1 week ago

Question

Create an implementation of a 2-3 tree using a linked strategy.

Answered: 1 week ago