{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

quiz1_s04_sol - 1.00/1.001 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/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
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
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. TRUE 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 FALSE 3) final variables must be initialized before they are used and cannot be modified thereafter. TRUE FALSE 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 FALSE 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() . TRUE FALSE 1.00/1.001 Spring 2004 Quiz 1 2/10 03/05/2004
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() +
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