Question 1 Analyze this code below. Is myDogs an array? Yes (True) or No (False). package...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Question 1 Analyze this code below. Is myDogs an array? Yes (True) or No (False). package uur ty_class_session; public class FinalReview { O O public public static void main(String[] args) } True False int[] myint List = new int [4]; //list of primitive data types for (int index= 0; index < < myintList.length; index++) { myintList [index] = 100; } String[] candybars = new String [5]; //list of class definitions for (int index = 0; index < candybars. length; index++) { candybars [index] = "Candy Bar Name " + (index+1); } Dog [1] myDogs = new Dog [3]; //list of class definitions for (int index= 0; index < < myDogs.length; index++) { myDogs [index] = new Dog(); } System.out.println (myDogs [0].getBreed()); 5 pts Question 2 Suppose that we had: int[] myFavNumbers = new int[3]; int[] yourFavNumbers = new int[3]; for (int index = 0; index < 3; index++) { } myFavNumbers[index] = 7; yourFavNumbers[index] = 7; Will (myFavNumbers == yourFavNumbers) evaluate to True or False? True O False 5 pts package during_class_session; public class Flower } private String NameofFlower; private double PriceofFlower; public Flower() { this.setNameofFlower("No name yet"); this.setPriceofFlower (0.0); } public Flower (String nameofFlower_initial, double priceofFlower_initial) { this.setNameofFlower (nameofFlower_initial); this.setPriceofFlower (priceofFlower_initial); } public String getNameofFlower() { return Name of Flower; } public void setNameofFlower (String nameofFlower) { NameofFlower = nameofFlower; public double getPriceofFlower() { return PriceofFlower; } public void setPriceofFlower (double priceofFlower) { PriceofFlower = priceofFlower; } } public String getNameofFlower() { return NameofFlower; } public void setNameofFlower (String nameofFlower) { NameofFlower = nameofFlower; Upload Choose a File } public double getPriceofFlower() { return Priceof Flower; } public void setPriceofFlower (double priceofFlower) { PriceofFlower = priceofFlower; } 1. Import it into Eclipse. Open the file in Eclipse 2. Edit the file to add comments to identify the instance variables, constructors headings and method headings 3. Edit the file to build and add the UML in the Header comment of the code. You must follow the format taught to you in the Ch. 8 Objects lesson. You must do a very thorough job and be sure to pay attention to the details. 4. Save your Flower.java file. 5. Upload your updated Flower.java file here. Question 4 Plan around 30 minutes for this question. Write a statement for each of the following. You may enter your answers below. Only statements are needed. No full program is needed. 1. (5 points) Create an int x and initialize it to 5. 2. (5 points) Write a statement to change the value of x to 25 3. (10 points) Write a statement to check if x is a an even number (x %2) will return 0 if x is an even number and will return 1 if x is an odd number as the % operator provides the remainder. 4. (10 points) Write a statement to create an array of 6 double values. You do not need to worry about the actual 6 data values - just create an array. 5. (10 points) Write a statement to create an array called StoreList designed to hold 2 Store Names of Strings 6. (10 points) Create an array called myFlowerList designed to hold 3 flowers of the data type Flower you set up above. 7.(10 points) Write a for loop that will start at index 0 of the myFlowerList and for each element of myFlowerList, create a new instance of Flower. To create a new instance, remember we use new Flower(); you need to finish the loop and make sure each data element is a new instance of flower Edit View Insert Format Tools Table BI U 12pt p Paragraph A T V 60 pts () 0 words Question 1 Analyze this code below. Is myDogs an array? Yes (True) or No (False). package uur ty_class_session; public class FinalReview { O O public public static void main(String[] args) } True False int[] myint List = new int [4]; //list of primitive data types for (int index= 0; index < < myintList.length; index++) { myintList [index] = 100; } String[] candybars = new String [5]; //list of class definitions for (int index = 0; index < candybars. length; index++) { candybars [index] = "Candy Bar Name " + (index+1); } Dog [1] myDogs = new Dog [3]; //list of class definitions for (int index= 0; index < < myDogs.length; index++) { myDogs [index] = new Dog(); } System.out.println (myDogs [0].getBreed()); 5 pts Question 2 Suppose that we had: int[] myFavNumbers = new int[3]; int[] yourFavNumbers = new int[3]; for (int index = 0; index < 3; index++) { } myFavNumbers[index] = 7; yourFavNumbers[index] = 7; Will (myFavNumbers == yourFavNumbers) evaluate to True or False? True O False 5 pts package during_class_session; public class Flower } private String NameofFlower; private double PriceofFlower; public Flower() { this.setNameofFlower("No name yet"); this.setPriceofFlower (0.0); } public Flower (String nameofFlower_initial, double priceofFlower_initial) { this.setNameofFlower (nameofFlower_initial); this.setPriceofFlower (priceofFlower_initial); } public String getNameofFlower() { return Name of Flower; } public void setNameofFlower (String nameofFlower) { NameofFlower = nameofFlower; public double getPriceofFlower() { return PriceofFlower; } public void setPriceofFlower (double priceofFlower) { PriceofFlower = priceofFlower; } } public String getNameofFlower() { return NameofFlower; } public void setNameofFlower (String nameofFlower) { NameofFlower = nameofFlower; Upload Choose a File } public double getPriceofFlower() { return Priceof Flower; } public void setPriceofFlower (double priceofFlower) { PriceofFlower = priceofFlower; } 1. Import it into Eclipse. Open the file in Eclipse 2. Edit the file to add comments to identify the instance variables, constructors headings and method headings 3. Edit the file to build and add the UML in the Header comment of the code. You must follow the format taught to you in the Ch. 8 Objects lesson. You must do a very thorough job and be sure to pay attention to the details. 4. Save your Flower.java file. 5. Upload your updated Flower.java file here. Question 4 Plan around 30 minutes for this question. Write a statement for each of the following. You may enter your answers below. Only statements are needed. No full program is needed. 1. (5 points) Create an int x and initialize it to 5. 2. (5 points) Write a statement to change the value of x to 25 3. (10 points) Write a statement to check if x is a an even number (x %2) will return 0 if x is an even number and will return 1 if x is an odd number as the % operator provides the remainder. 4. (10 points) Write a statement to create an array of 6 double values. You do not need to worry about the actual 6 data values - just create an array. 5. (10 points) Write a statement to create an array called StoreList designed to hold 2 Store Names of Strings 6. (10 points) Create an array called myFlowerList designed to hold 3 flowers of the data type Flower you set up above. 7.(10 points) Write a for loop that will start at index 0 of the myFlowerList and for each element of myFlowerList, create a new instance of Flower. To create a new instance, remember we use new Flower(); you need to finish the loop and make sure each data element is a new instance of flower Edit View Insert Format Tools Table BI U 12pt p Paragraph A T V 60 pts () 0 words
Expert Answer:
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
Refer to the bill of materials for product A shown in the figure below. If inventory consists of 2 units of B, 1 unit of F, and 3 units of G, how many units of G, E, and D must be purchased to...
-
answer the question clearly You are building a flight-control system for which a convincing safety case must be made. Would you assign the tasks of safety requirements engineering, test case...
-
Determine whether each relation defines y as a function of x. Give the domain. Identify any linear functions. y = |x|
-
Walgreens Boots Alliance, Inc. is a global pharmacy-led health and well-being enterprise. It has 13,100 stores in 11 countries. Walgreens Boots Alliance was incorporated in 2014 and is the successor...
-
Prove Theorem 4.7. Theorem 4.7 If X has the variance 2, Then var(aX + b) = a22
-
Stretching a certain spring \(0.10 \mathrm{~m}\) from its relaxed length requires \(18 \mathrm{~J}\) of work. How much more work does it take to stretch this spring an additional \(0.10 \mathrm{~m}\)...
-
Suppose the total benefit derived from a continuous decision, Q, is B(Q) = 20Q 2Q2 and the corresponding total cost is C(Q) = 4 + 2Q2, so that MB(Q) = 20 4Q and MC(Q) = 4Q. a. What is total benefit...
-
Consider the topology. 1. Replicate the topology in Packet Tracer. 2. Configure the IP settings and static routes using next hop addresses (optional: you may use loopback interfaces on the routers if...
-
We need to swap the following registers. Do this using block moves. Before r1 r2 r3 r4 r5 r6 r7 After r3 r4 r5 r6 r7 r1 r2
-
Find the general solution of du (y- z) +(x z) + (2y 2x). 3D0 az x
-
Discuss the circumstances under which the corporate veil of Tulonga (Pty) Ltd may be lifted under Namibian company law. Discuss the conditions that are applied by the courts in Namibia when...
-
A convex lens of focal length 25 cm forms an image on a screen placed 1.5 cm from it's center. Determine a) the position of the object b) The magnification
-
What would make a personality test reliable and valid?
-
Cairo Inc. owns a bond that is accounted for using the cost/amortized cost model. At the reporting period's end, the carrying value of the bond is $960,000. Management believes that the fair market...
-
Game: Extensive Form. Suppose player 1 chooses G or H, and player 2 observes this choice. If player 1 chooses H, then player 2 must choose A or B. Player 1 does not get to observe this choice by...
-
A horizontal circular disk with mass m and radius 2r can rotate easily about its vertical axis of symmetry O. A small boy with mass km starts in A, when the system is at rest, and runs along the...
-
(a) With not more than 300 words, examine why Malaysia missed its 2020 targets to divert 40% of waste from landfills and increase recycling rates to 22%. (10 marks) b) Why arent Malaysian recycling?...
-
The nine tails problem in the text uses a 3 * 3 matrix. Assume that you have 16 coins placed in a 4 * 4 matrix. Write a program to find out the number of the starting patterns that dont have a...
-
Write a program that simulates a stopwatch, as shown in Figure 16.45a. When the user clicks the Start button, the button?s label is changed to Pause, as shown in Figure 16.45b. When the user clicks...
-
Suppose that the text file on the Web http://cs.armstrong.edu/liang/data/Scores.txt contains an unspecified number of scores. Write a program that reads the scores from the file and displays their...
-
Over what ranges of taxable income in 2017 will the total income tax liability for two persons with equal incomes who file as single individuals equal their income tax liability if they file jointly...
-
If a taxpayer has $40,000 of employee salary in 2017, how much will be withheld for the Social Security and Medicare taxes?
-
Sally and Jim are married and have taxable income in 2017 of $160,000. If they could file their income tax as single individuals, each of them would have taxable income of $80,000. Do they have a...
Study smarter with the SolutionInn App