English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

What is the output from this program?

double[] c = { 1.1, 17.9, 32.1, 96.8, 101.5 };
double[] d = c;

c[ 2 ] = d[ 2 ] + 1.0;

System.out.println( d[ 2 ] );

A) 17.9

B) 18.9

C) 32.1

D) 33.1

E) None of these

2007-05-15 07:56:15 · 5 answers · asked by Anonymous in Computers & Internet Programming & Design

5 answers

33.1..

both arrays r in same address

jj

2007-05-15 08:12:43 · answer #1 · answered by JJ 4 · 1 1

the answer is D
Array indices in java start from 0. so c[2] = 32.1

2007-05-15 08:08:39 · answer #2 · answered by max 4 · 0 0

Should be A) 17.9 because d=c and c2 = 17.9 so d2 would be 17.9

This really should go into the "homework help" section of Answers though... but good luck on your school work.

2007-05-15 08:01:15 · answer #3 · answered by spl 4 · 0 2

public type cities { public static void substantial(String[] args) { String[][] cities = { { "long island", "l. a.", "San Francisco", "Chicago" }, { "Munich", "Stuttgart", "Berlin", "Bonn" }, { "Paris", "Ajaccio", "Lyon" }, { "Montreal", "Ottawa", "Vancouver" } }; int count variety = 0; for (int i = 0; i < cities.length; i++) { for (int j = 0; j < cities[i].length; j++) { String message = String .format("[%d] %s", ++count variety, cities[i][j]); equipment.out.println(message); } } equipment.out.println("count variety is " + count variety); } } // output: [a million] long island [2] l. a. [3] San Francisco [4] Chicago [5] Munich [6] Stuttgart [7] Berlin [8] Bonn [9] Paris [10] Ajaccio [11] Lyon [12] Montreal [13] Ottawa [14] Vancouver count variety is 14

2016-11-23 14:53:33 · answer #4 · answered by Anonymous · 0 0

d. 33.1

2007-05-15 08:06:10 · answer #5 · answered by Andy T 7 · 0 0

fedest.com, questions and answers