review 04 Version A noh3Xe

review 04 Version A noh3Xe - 1) Part One: a) Define a...

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

View Full Document Right Arrow Icon
Sheet1 1) Part One: a)Define a class. A class is a blueprint, or prototype, that defines the variables and the methods common to all objects of a given kind b)What are the two major constituents of a class? Methods and variables c)How many kinds of classes are available for use in JAVA? Public, Private, Protected d)Which of the above classes allow inheritance? Public 2) import java.applet.* import java.awt.Color import java.awt.Graphics public class TrivialApplet extends Applet { final int width = 300, height = 300 public void paint ( Graphics gr ) { gr.setColor( Color.red ) int radius = 20 int width = 2*radius int height = 2*radius int rowCount = 0 int squareX = 80 int squareY = 100 while ( rowCount < 3 ) { int squareCount = rowCount +1 int x = squareX for ( int i = 0 { gr.drawRect( x, squareY, width, height ) gr.drawOval( x, squareY, 2*radius, 2*radius) x += ( 2 * width ) } squareX -= width squareY += height ++rowCount } rowCount = 3 Page 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
Sheet1 squareX = 0 while ( rowCount > 0 ) { int x = squareX for ( int i = rowCount { gr.drawRect( x, squareY, width, height ) gr.drawOval( x, squareY, 2*radius, 2*radius) x += ( 2 * width ) } squareX += width squareY += height --rowCount } } }
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 / 13

review 04 Version A noh3Xe - 1) Part One: a) Define a...

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