AP COMPUTER SCIENCE A STUDY DAY STARTER PROGRAMMING QUESTIONS Solutions can
be found at the bottom of this page. QUESTION 1
(FOR LOOP) Write a program that uses a for-loops to output all
odd numbers from 1 to 100 to screen.
All numbers should appear on a single line separated by a comma. QUESTION 2
(ARRAY, FOR LOOP) Consider the array: int[] arr = {4, 5, 2, 9, 0, 4, 2, 8, 1, 9, 3, 0, 2,
9} Write the code needed (using a for loop) to total up
the array. Output the total to screen. QUESTION 2B (2D
ARRAY) Create a 2D array that represents the number grid
below using nested for loops to initialize each element. Then, using two more nested for loops,
output your 2D array to screen. 1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 QUESTION 3 (ARRAYLIST) Do the following steps relating to Arraylists: a) Create
an arraylist named al that holds integers.
b) Add
the value 8 to it. c) Add
the value 9 to it. d) Add
the value 3 at the beginning of it. e) Add
the value 4 to the end of it. f) Add
any three other values to the arraylist. g) Output
the size of the arraylist to screen. h) Output
the arraylist to screen. i) Remove
the first element from the arraylist. j) Set
the first element to 22. k) Output
to screen the element at index 3. l) Output
the arraylist to screen. m) Write
a for loop that will go over the arraylist to find the maximum value in the
list. Output that max value. QUESTION 4
(IMPLEMENTING CLASSES) Do the following problem sourced from our course’s
OOP Guide.
QUESTION 5
(INTERFACES) Consider the following Area interface and the
Rectangle class. Make the Rectangle
class implement the interface.
SOLUTIONS Question 1 | Question
2 | Question 2B | Question
3 | Question 4 | Question
5 |