Write Java statements to accomplish each of the following tasks:

a) Display the value of element 6 of array f.
b) Initialize each of the five elements of one-dimensional integer array g to 8.
c) Total the 100 elements of floating-point array c.
d) Copy 11-element array a into the first portion of array b, which contains 34 elements.


```
a) System.out.print(f[6]);
b) int g[] = {8, 8, 8, 8, 8};
c) for (int k = 0; k < c.length; k++)
total += c[k];
d) for ( int j = 0; j < a.length; j++ )
b[ j ] = a[ j ];
```

Computer Science & Information Technology

You might also like to view...

Answer the following statements true (T) or false (F)

1) A set is an ordered collection of elements. 2) map, each value has a unique key. 3) The elements in a map are unique. 4) The contains operation of the Set interface returns a count of the number of occurrences of an element in the set 5) When instantiating an implementation of a Map interface, a type must be supplied for both the key and for the value.

Computer Science & Information Technology

Comment out the word “synchronized” in the heading of the method update. Compile and run RunThread3 again. What is the outcome? Explain.

Consider the following Java classes: ``` import SomeThread3; public class RunThreads3 { public static void main (String[] args) { int originalThreadCount = Thread.activeCount( ); for (int i=0; i<10; i++) { Thread p = new Thread(new SomeThread3()); p.start(); System.out.println("thread count=" +Thread.activeCount( )); } while (Thread.activeCount() > originalThreadCount ){ // loop until all child threads have exited. } System.out.println("finally, Count = " + SomeThread3.count); } }//end class RunThreads3 class SomeThread3 implements Runnable { static int count=0; SomeThread3() { super(); } public void run() { update(); } static public synchronized void update( ){ int myCount = count; int second = (int)(Math.random( ) * 500); try { Thread.sleep(second); } catch (InterruptedException e) { } myCount++; count = myCount; System.out.println("count="+count+ "; thread count=" + Thread.activeCount( )); } } //end class SomeThread3 ```

Computer Science & Information Technology

____ Preview lets you see how a gallery option affects your file without making the change.

A. Active B. Window C. Live D. Instant

Computer Science & Information Technology

Describe various types of servers in a network.

What will be an ideal response?

Computer Science & Information Technology