2001ACTestAnswers

2001ACTestAnswers - C ompSci 101 AC - 2001 Terms Test...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CompSci 101 AC - 2001 Terms Test Answers Question 1: Output from class Q1 : 6 1 5.0 4.0 5.0 Question 2: The completed actionPerformed() method for the class Q2 : public void actionPerformed(ActionEvent e) { String s1 = tOne.getText(); String s2 = tTwo.getText(); tOne.setText(s2); tTwo.setText(s1); } Question 3: The complete Q3 class: import java.awt.*; import java.applet.*; public class Q3 extends Applet { public void paint(Graphics g) { final int SIZE = 25; g.drawRect(0, 0, 2*SIZE, 2*SIZE); g.drawRect(2*SIZE, 2*SIZE, 2*SIZE, 2*SIZE); g.drawOval(0, 2*SIZE, 2*SIZE, 2*SIZE); g.drawOval(2*SIZE, 0, 2*SIZE, 2*SIZE); g.drawLine(SIZE, SIZE, 3*SIZE, 3*SIZE); g.drawLine(SIZE, 3*SIZE, 3*SIZE, SIZE); } }
Background image of page 1

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

View Full DocumentRight Arrow Icon
Question 4: The complete Q4 class: import java.awt.*; import java.applet.*; import java.awt.event.*; public class Q4 extends Applet implements MouseListener { private TextField tXChange, tYChange; private int prevX, prevY, currentX, currentY; public void init() { tXChange = new TextField("0 ");
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

2001ACTestAnswers - C ompSci 101 AC - 2001 Terms Test...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online