Questions? Email

Join our weChat group or follow us on Facebook

©2019 by Legion of Learners

Feb 23

Test Prep 5 - FRQ Array Problems


Edited: Oct 14

A. 1-D Array (Example 1: FRQ#4 of 2018 sample solutions)

  1. How to declare and initialize an array of varied length?

  2. How to traverse an array using for loops and for-each loops to find the max/min/total/mean?

  3. How to create an array of Money or Date objects?

  4. How to use Array variables in a class? (as instance variables, static variables or local variables)

  5. How to pass an array as a parameter to a method or take an array as a return value?

B. 2-D Array (Example 2: FRQ#4 of 2017 )

  1. Is a 2-D array(matrix) an array of 1-D / row arrays?

  2. How to traverse a 2-D array using nested for loops or for-each loops?

  3. How to pass a 2-D array as a parameter or take a 2-D array as a return value?

C. What is the best or worst case of an array algorithm?

When traversing an array to process, depends on the situation, the amount of processing may vary. The best case is when the necessary procession is the least, the worst case is when the necessary procession is the most.


D. What is the disadvantage of arrays?

Inefficient to insert or delete elements.


E. Practice of the week:

  1. All array questions of Chapter 7 "Arrays and Array Lists" (Barron's)

  2. FRQ#3 of 2016

New Posts
  • sfolax6776
    Oct 28

    A. Introduction Anything is possible if you can program... :) B. Watch (Slides) C. Try: 1) Do you know ArrayList class is implemented by an array? 2) Can you implement insert/remove for 2-D arrays?
  • sfolax6776
    Oct 28

    A. Introduction Arrays are powerful but their sizes are fixed once declared. To overcome the inconvenience, array lists are introduced in Java. Array lists are implemented by arrays behind the scene but to end users, they are resizable. B. Watch ( Slides ) C. Try: E.7.11-E7.14 of Big Java Early Obejcts
  • sfolax6776
    Oct 28

    A. Introduction Now you are well equipped with the skills to create an array of 300 students, - not only their height or weight, but ALL info of these students. You define what you'd like to include in class Students, and then create an array of 300 Student objects. Each object may have a student's name, birthday, height, weight, gpa... B. Watch ( slides ) C. Try 1) Use class Person below to create an array of x persons. Prompt a user to enter x as numbers of persons to create, then input name and age of each person to fill the array. public class Person { private String name; private int age; public Person(String aName, int anAge) { name = aName; age = anAge; } /* @return the String form of this person / public String toString() { return name + " " + age; } public void printPerson() { System.out.println(this); } public void setName(String newName) { name = newName; } public void setAge(int newAge) { age = newAge; } } 2) Split the array above into two or more age groups, create a new array for each age group. 3) Create a 2-D array of Person to store different age groups: <12 years old, 12-18 years old, >18 years old. Assume each age group will have a maximum of 5 people.