spring2004quiz2 (1)

spring2004quiz2 (1) - 1.00/1.001 Introduction to Computers...

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

View Full Document Right Arrow Icon
1.00/1.001 Introduction to Computers and Engineering Problem Solving Quiz 2: April 16, 2004 Name: Email Address: TA: Section: You have 80 minutes to complete this exam. For coding questions, you do not need to include comments, and you should assume that all the necessary files have already been imported. Good luck. Question Points Question 1 / 10 Question 2 / 20 Question 3 / 20 Question 4 / 30 Question 5 / 20 Total / 100 1.00/1.001 Spring 2004 Quiz 2 1/9 04/16/2004
Background image of page 1

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

View Full DocumentRight Arrow Icon
Problem 1: Abstract Classes & Interfaces (10 points) Consider an abstract class Animal , a concrete class Bird derived from Animal , a concrete class Cuckoo derived from Bird and an interface IColor implemented by the Bird class. public class AnimalTest ± { ± public static void main(String[] args) ± { ± Animal a1; //Statement 1 ± } ± } ± Animal a2 = new Animal(); //Statement 2 Animal a3 = new Bird(); //Statement 3 Animal a4 = new Cuckoo(); //Statement 4 Bird b1 = new Bird(); //Statement 5 Bird b2 = new Animal(); //Statement 6 Bird b3 = new Cuckoo(); //Statement 7 Cuckoo c1 = new Bird(); //Statement 8 IColor myColor; //Statement 9 ± IColor myColor2 = new IColor(); //Statement 10 Given the above statements, please circle the one(s) that would issue a compilation error. 1 2 3 4 5 6 7 8 9 10 1.00/1.001 Spring 2004 Quiz 2 2/9 04/16/2004
Background image of page 2
Problem 2: Inner and Nested Classes (20 points) Class Employee contains data and methods describing the hard-working staff at MIT. Please help complete the methods inside this class as requested in the two boxes below. public class Employee { public static String officeLoc = "77 Massachusetts Av"; private String name = ""; private double age = 0.0; public static String phoneNo = "234-567-0000"; public Employee( String n, double a ) { name = n; age = a; } public class Record{ // Complete printRecord() , a method to output employee ± // data using all of the Employee variable(s) that can be ± // accessed by this method. Use System.out.println() for± // output. ± public void printRecord(){
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.

Page1 / 9

spring2004quiz2 (1) - 1.00/1.001 Introduction to Computers...

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