{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

2001ACExamQuestions

# 2001ACExamQuestions - Question Answer Sheet-2 CompSci 101...

This preview shows pages 1–4. Sign up to view the full content.

Question / Answer Sheet - 2 - CompSci 101 AC Surname: . ........................................ Forenames: . ................................... CONTINUED Question 1 (6 marks) i) Declare and create an array of String elements called allStrings which is large enough to contain 300 String elements: ii) Assign the String , " Relax " to the 10 th element of the allStrings array: iii) Assign the length of the 10 th element of the allStrings array to the int variable called len : int len; (6 marks)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Question / Answer Sheet - 3 - CompSci 101 AC Surname: . ........................................ Forenames: . ................................... CONTINUED Question 2 (15 marks) Complete the code (in the spaces provided) for the following applet which executes as follows: When the user presses the mouse, a Point object is created (storing the location of the mouse press) and added to an array of Point objects. In the applet a square is drawn at the position of each Point object in the array; the mouse press position is at the middle position of the square. The size of each square drawn in the applet increases by one pixel as we move through the array. eg. the square at the first Point object in the array is of size 2 pixels, the square at the second Point object is of size 3 pixels, the square at the third Point object is of size 4 pixels etc. Whenever the user presses the " MOVE LEFT " button the x value of all the Point objects in the array decreases by 2; this means that all the points are drawn 2 pixels to the left of their previous position. The following screen shots show the completed applet in action. In the screen shot on the left below, the user has pressed the mouse button three times. At each location that the mouse was pressed, a small blue square is drawn with the middle of the square at the position of the mouse press. Each time the mouse button is pressed, the new square that is drawn is one pixel larger than the previous square. In the screen shot on the right below, the user has continued pressing the mouse many times from the top left towards the bottom right of the applet window. The squares drawn at the position of the mouse presses become larger from the top left to the bottom right of the applet. In the screen shot on the left below, the user has pressed the " MOVE LEFT " button ten times, and all the squares have moved 20 pixels towards the left of the applet. In the screen shot to the right, the user has continued to press the " MOVE LEFT " button another ten times, and the squares have moved another 20 pixels further to the left.
Question / Answer Sheet - 4 - CompSci 101 AC Surname: . ........................................ Forenames: . ................................... CONTINUED

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 25

2001ACExamQuestions - Question Answer Sheet-2 CompSci 101...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online