Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

pls solve all questions thank you so much! 2. Write a statement that creates and initializes a double array with the following values: 1.7,6.4,8.9,3.1,9.2? 3.

image text in transcribed
image text in transcribed
image text in transcribed
pls solve all questions thank you so much!
2. Write a statement that creates and initializes a double array with the following values: 1.7,6.4,8.9,3.1,9.2? 3. Which of the following statements are valid? a) int i = new int (30); b) double d[] = new double [30]; c) char[] r = new char(1..30); d) int il = (3, 4, 3, 2); e) float ful [2.3, 4.5, 6.6); f) char() c = new char(); 4. Write statements to do the following: a) Create an array to hold 10 double values. b) Assign the value 5.5 to the last element in the array. c) Display the sum of the first two elements. d) Write a loop that computes the sum of all elements in the array. e) Write a loop that finds the minimum element in the array. f) Randomly generate an index and display the element of this index in the array. g) Use an array initializer to create another array with the initial values 3.5, 5.5, 4.52, and 5.6. 5. Which of the following statements are valid? a) intill r = new int [2]; b) int[] x = new int[]; c) int[] [] y = new int [3111: d) int[] [] 2 {{1, 2}} e) int[] [] m = {{1, 2), 12, 313 f) int[] [ln {{1, 2), (2, 3), ); 6. Look at the following array definition: double[] [] sales = new double [8] [10]; a) How many rows does the array have? b) How many columns does the array have? c) How many elements does the array have? d) Write a statement that stores a number in the last column of the last row in the array 7. When the same name is used for two or more methods in the same class, how does Java tell them apart? 8. Look at the following partial class definition, and then respond to the questions that follow it: public class Book { private String title; private String author; private String publisher; private int copies Sold; } a. Write a constructor for this class. The constructor should accept an argument for each of the fields. b. Write accessor and mutator methods for each field. Draw a UML diagram for the class, including the methods you have written. c. 1. 9. Consider the following class declaration: public class Thing { private int x; private int y; private static int z = 0; public Thingo) { * = 2; y - z; ) static void put Thing(int a) > Assume a program containing the class declaration defines three Thing objects with the following statements: Thing one = new Thing(); Thing two - new Thing(); Thing three = new Thing(); a. How many separate instances of the x member exist? b. How many separate instances of the y member exist? c. How many separate instances of the z member exist? d. What value will be stored in the x and y members of each object? Write a statement that will call the putThing method

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

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

What must a creditor do to become a secured party?

Answered: 1 week ago

Question

When should the last word in a title be capitalized?

Answered: 1 week ago