The class Demo is defined as follows: class Demo { private int vall; private int val2;...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
class Demo private int val1 private int val2 public void setValuesint num1 int num2 val1 num1 val2 n... View the full answer
Related Book For
Java Software Structures Designing And Using Data Structures
ISBN: 9780133250121
4th Edition
Authors: John Lewis, Joe Chase
Posted Date:
Students also viewed these programming questions
-
1. You will be implementing the Generalized Arc Consistency (GAC) algorithm described in Chapter 4 of the textbook. In particular, you will be implementing the while loop shown in Figure 4.3:...
-
This question concerns lexical grammars. (a) Tree Adjoining Grammars contain two types of elementary tree. (i) What are these trees called? [1 mark] (ii) If one were building a grammar for English...
-
Neo-Darwinism believes that new species develop through (A).Continuous variations and natural selection (B) Mutation with natural selection (C) Hybridization (D) Mutation
-
What are the four customer relationship groups? Is there a way marketers can mare a Stranger to a True Friend? Explain how Apple and BMW would move their Strangers to True Friends.
-
The unadjusted trial balance of Avery Air Purification System at December 31, 2024, and the data needed for the adjustments follow. Adjustment data at December 31 follow: a. On December 15, Avery...
-
Tax-deductibility of clean-up costsasset or liability? The IRS [US Inland Revenue Service] reversed its position on the accounting treatment of environmental clean-up costs in Revenue Ruling 94-38....
-
2015, Aron Company purchases 100% of the common stock of Shield Company for $450,000 cash. On this date, any excess of cost over book value is attributed to accounts with fair values that differ from...
-
A firm has total sales of $32 million. It has gross profit of $11 million, operating income of $9 million, and net income of $3 million. What is the firm's net profit margin? Question 10 options:...
-
Brian and Corrine Lee are married taxpayers filing jointly. They live in the home they own, located at 3301 Pacific Coast Hwy., Laguna Beach, CA 92651. Brian is an optometrist who owns his business;...
-
Design a 5 1/2" O.D. casing string to 16,500 ft, using any of the P- 110 casing weights. Assume worst possible conditions (no backup for burst or collapse, etc.). Use the API design factors (Collapse...
-
One of the most divisive topics in the history of U.S. politics is how our economy is structured. Views on the government's involvement in the economy reinforce political parties, party ties, and...
-
"It costs a lot of money to make an album in a studio in New York with a producer and musicians. I have to pay a publicist every month. I have to pay for mastering, production, the manufacturing of...
-
Consider the wholesale market for electricity in Australia where wholesale electricity prices are determined by the interaction of market demand and supply curve. Explain, using demand and supply...
-
Financial leverage Max Small has outstanding school loans that require a monthly payment of $1,080. He needs to buy a new car for work and estimates that this purchase will add $346 per month to his...
-
Provide explanation of each transaction, and in ste Indicate the effect of each of the following transactions on assets, liabilities, and owner's equity by inserting ??+? for increase and ??-? for...
-
3. Let 01 012 -11 1 02-3 Find, if possible, AA and AT A. Are they equal? Is it true that (AA) =AAT? Is it true that (ATA) = ATA?
-
The following data are supplied for the common stocks of Nikola Corporation, Tesla, Inc. and General Motors: Nikola Corp (NKLA) Tesla Inc. (TSLA) Close Price ($) Close Price ($) 67.53 30.00 40.81...
-
Create a tree-based implementation of a TreeBag class. Remember, the difference is that a bag allows duplicates.
-
Write a while loop that uses an explicit iterator to accomplish the same thing as Exercise 7.1. Exercise 7.1. Write a for-each loop that prints all elements in a collection of Student objects called...
-
Create an implementation of a 2-3 tree using a linked strategy.
-
In addition to the fuel hose, a __________________ is connected between the fuel truck and the aircraft when refueling.
-
True or False: The technician must never enter the tank of a transport category aircraft.
-
Fuel __________________ is an important parameter that merits the use of a warning signal when it falls outside of the normal operating range.
Study smarter with the SolutionInn App