quiz1_s04_sol

Quiz1_s04_sol - 1.00/1.001 Introduction to Computers and Engineering Problem Solving Quiz 1 March 5 2004 Name Email Address TA Section You have 80

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 1 March 5, 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 / 15 Question 3 / 20 Question 4 / 20 Question 5 / 17 Question 6 / 18 Total / 100 1.00/1.001 Spring 2004 Quiz 1 1/10 03/05/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
Question 1. True/False (10 Points) Answer the following questions by circling TRUE or FALSE as appropriate. 1) It is legal to have two methods whose signatures differ only by their return types. T R U E FALSE 2) Because arrays are passed to methods as references, the called methods can modify the element values in the caller’s original arrays. TRUE F A L S E 3) final variables must be initialized before they are used and cannot be modified thereafter. TRUE F A L S E 4) When an object a of a class Test has a reference to another object b of the same class, a can access all of b ’s data and methods. TRUE F A L S E 5) If a method m() defines a local variable a with the same name as a variable with class scope, there is no way to access the instance variable from inside m() . T R U E FALSE 1.00/1.001 Spring 2004 Quiz 1 2/10 03/05/2004
Background image of page 2
Question 2. Objects and Variables (15 Points) public class Robot { private static int ID = 0; private int serialNumber; private String name; private int myID; public Robot(String robotName, int sNum) { serialNumber = sNum; name = robotName; myID= ID++; } public static int getID(){return ID;} public int getSerial(){return serialNumber;} public void setSerial(int sNum){serialNumber = sNum;} public int getMyID() { return myID;} } In order to test the above class, you write the following: public class Test { public static void main(String[] args) { System.out.println("Current ID: " + Robot.getID()); Robot robot1 = new Robot("Rod", 3239); System.out.println("Robot 1 ID: " + robot1.getID() + " Serial: " + robot1.getSerial()); Robot robot2 = new Robot("Jon", 2364);
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 11/29/2011 for the course CIVIL 1.00 taught by Professor Georgekocur during the Spring '05 term at MIT.

Page1 / 10

Quiz1_s04_sol - 1.00/1.001 Introduction to Computers and Engineering Problem Solving Quiz 1 March 5 2004 Name Email Address TA Section You have 80

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