{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

spring2004quiz2 - 1.00 Introduction to Computers and...

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

View Full Document Right Arrow Icon
1.00 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 Spring 2004 Quiz 2 1/9 04/16/2004
Image of page 1

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

View Full Document Right 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 Spring 2004 Quiz 2 2/9 04/16/2004
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. ±
Image of page 3

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern