Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HS58 Quiz_1_Section_763 Q Home Insert Design Layout References Mailings Review View Share X LE A A Aa A EvEve 33 21 ( Aarbecndfe Aarbondre AaBbccc

image text in transcribedimage text in transcribed

HS58 Quiz_1_Section_763 Q Home Insert Design Layout References Mailings Review View Share X LE A A Aa A EvEve 33 21 ( Aarbecndfe Aarbondre AaBbccc 23h-DE: Aabbccdte Paste I U Normal No Spacing Heading 1 Heading 2 Heading 3 Styles Pane Activate Subscription Required to edit and Save Start your free one month trial of Microsoft 365 or sign in to activate an existing subscription. Design a class called My Numbers that has one field: a. A reference to an array of ints called gyros (private). 1. Provide 3 constructors to the class My Numbers a. A full-argument constructor that will take as input u reference to an array of characters to initialize the nums field. public My Numberslintul gums) { } b. A no-argument constructor that will initialize the nums field to null public My Numbers0 { } c. A copy constructor that will take as input a reference to MyNumbers object to initialize the nums field. public MxNumber(My Numbers other) { } Hint: Check that input argument is not null using Obiects.reguire Non NullO method. 2. Provide getter and setter to access and update the nums field. public intll get umso } public void setNumsaint pams) { 3. Override the toString) method to print the content of the array gums using the following format: Hint: This output assumes that the array referenced by nums contains: [1, 2, 3, 4, 5, 6, 7, 8, 91 [1, 2, 3, 4, 5, 6, 7, 8, 91 @Override public String toString() { } 4. Override the equals method to return true if the content of the two gumos arrays are identical and false otherwise @Override public boolean eguals(Object other) { 502 words X English (United States) E FSIE - + 104% % HS58 Quiz_1_Section_763 Q Home Insert Design Layout References Mailings Review View Share X LS A A Aa A EvEve 33 21 ( Aarbecndfe Aalbode AaBbccc 23h-DE: Aabbccdte Paste BI U Normal No Spacing Heading 1 Heading 2 Heading 3 Styles Pane Subscription Required to edit and Save Start your free one month trial of Microsoft 365 or sign in to activate an existing subscription Activate } Hint: If the two nums arrays have different lengths, equals() should return false! 5. Provide a numberAt() method that takes an int argument to return the number located at the input argument index. public int numberAt(int index) { } Hint: If the index is negative or exceeds the number of ints, the method should throw an IlegalArgumentException. 6. Complete the main() in the TestQuizl class where you will: a. Initialize an array of ints to {9, 8, 7, 6, 5, 4, 3, 2, 1, 0} b. Create an object of MyNumbers by calling the full-argument constructor and passing to it the initialized array. c. Create an object of MyNumbers by calling the copy constructor and passing to it the reference to the first MyNumbers object. d. Create an object of MyNumbers by calling the no-argument constructor. e. Call the setNums() method to update the content of the third object to the following: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}. f. Compare the content of the first and second MyNumbers objects using the equals() method. g. Print the content of the third object using the toString0 method. h. Get the 4th element in the third MyNumbers object using the numberAt() method and print it on the output screen. Inautant Notod 502 words English (United States) 197%

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions

Question

7. Do the organizations social activities reflect diversity?

Answered: 1 week ago

Question

What qualities do you see as necessary for your line of work?

Answered: 1 week ago