2000FCTestAnswers

2000FCTestAnswers - 415.101FC PRINCIPLES OF PROGRAMMING...

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

View Full Document Right Arrow Icon
415.101FC PRINCIPLES OF PROGRAMMING ANSWER BOOK Test - Tuesday 11th April 6:30pm-8:00pm 1. Draw the output. 2. Corrected program (with changes CIRCLED): 1) Word static missing from main() declaration 2) variable toss is not declared 3) the = sign should be == in the if statement 4) semicolon missing from first println() statement 5) Logic error. Should be: toss = (int)(Math.random()*2);
Background image of page 1

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

View Full DocumentRight Arrow Icon
3. Complete the paint() method import java.awt.*; import java.applet.*; public class ScaleMe extends Applet { public void paint(Graphics g) { final int SIZE = 50; g.drawRect(SIZE, SIZE, SIZE, SIZE); g.drawOval(0, 0, 3*SIZE, 3*SIZE); g.drawLine(SIZE, SIZE, 2*SIZE, 2*SIZE); g.drawLine(SIZE, 2*SIZE, 2*SIZE, SIZE); } 4. Output from class Types: a) 2.0 b) 4.5 c) 11.0 d) 2 e) 8 5. Output from class MethodTester: From first:1 From first:2 From second:2 From first:3 From first:4 From second:4 From third:4 From init:4
Background image of page 2
6. Complete the FillBeaker applet.: import java.awt.*; import java.awt.event.*; import java.applet.*;
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/01/2012 for the course COMPSCI 101 taught by Professor Adrianaferraro during the Summer '12 term at Auckland.

Page1 / 5

2000FCTestAnswers - 415.101FC PRINCIPLES OF PROGRAMMING...

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

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