Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Simple Java question 2

BunkerHillBroad
BunkerHillBroad 


The following simple program, which is supposed to create a 20-element array that it fills with random integer values, contains a number of distinct errors. Some of the mistakes will cause an error message at compilation time, while others may cause an error at execution time. Find (and fix) all of them! class Foobar { public static void main (String [] args) { double [20] r; for (int i = 0; i <= r.length(); i++) r[i] = Math.random * 100; } } Attachments
Tags Clarifications

Answers

Simple Java question 2-Solution

mariobeka
mariobeka 



Open the solution file with any text editor. Attachments Screenshots
Purchase Answer

Simple Java question 2

uetian_cute
uetian_cute 



Total 4 errors were corrected.
3 at compile time and 1 at runtime.
Attachments
Foobar.zip (1 K) Download
Preview
{ /*Error 1 in array declaration*/ double [] r=new double[20]; /*error 2 in length * *

Screenshots
Purchase Answer