Everybody loves practice problems, right? OK, not everybody. But if you want practice problems for the test, here you go!
1. Write a procedure fiboArray that takes an array of ints as its input and populates it with the Fibonacci numbers. Positions 0 and 1 should be assigned values of 1 and subsequent elements in the array should be the sum of the previous two elements.
2. Write fiboArrayList for an ArrayList<Integer>. Note that you will need a second argument of type int, which will indicate how many elements should be put into the ArrayList. A precondition for calling fiboArrayList is that this number must be at least 2.
3. Write concatenateArray that takes an array of Strings and returns a single String containing all of the elements concatenated.
String strs = new String; strs = "Now"; strs = "here"; strs = " "; // String contains a single blank strs = "Man"; System.out.println(concatenateArray(strs)); // prints "Nowhere Man"
4. Write a method that takes in a two-dimensional array of doubles and returns the sum of all of its elements. Hint: remember that if you have an array as shown below:
double d = new double;
then d.length is 5 and d.length is 7.