CSE 131 Module 7: Array Structures

Given Quiz

Name (print CLEARLY) ___________________________________   Lab Section you attend______________

CSE131 Quiz 7
Array Structures
31 Oct 2008

  1. Complete the method below, which takes in an array of ints and returns true if all of the values are positive (> 0) and false otherwise.
    public static boolean arePosiive(int[] values) {
  2. Complete the method below so that it returns an array ans such that ans[i] is true if and only if trick[i] or treat[i] is true.
    public boolean[] trickOrTreat(boolean trick[], boolean treat[]) {
       // fill in below so that an exception is thrown if trick and treat are
       //    not arrays of the same length
       if (                                              )
          throw new IllegalArgumentException("incompatible lengths");
       boolean[] ans = new boolean[trick.length];
       return ans;

Solution not yet available.