quiz1solutions

# quiz1solutions - 1.00/1.001 Introduction to Computers and...

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

1.00/1.001 Introduction to Computers and Engineering Problem Solving Quiz 1 / October 7, 2005 Name: Email Address: TA: Section: Question Points Question 1 / 15 Question 2 / 25 Question 3 / 10 Question 4 / 40 Question 5 / 10 Total / 100 You have 90 minutes to complete this exam. For coding questions, you do not need to include comments, and you should assume that all necessary files have already been imported. Good luck. HW1 HW2 HW3 1.00/1.001 Quiz 1 1/10 10/07/2004

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

View Full Document
Question 1. Data variables / operators (15 points) What is the value of ‘ i ’ when the following statements are executed: 1. int i = -4 + 8/3 + 1%2; i = -1 2. double i = -4 + 8/3 + 1%2; i = -1.0 3. int i = -4 + 8.0/3 +1%2; i = Error 4. float i = -4 + 8.0F/3 + 1%2; i = -0.33 5. int i = -4 + 8/(3 - 1)%2; i = -4 1.00/1.001 Quiz 1 2/10 10/07/2004
the correct answer(s) from the multiple choices as appropriate. 1. A static data member is shared by all instances of that class. TRUE F A L S E 2. A static data member’s value can never change. T R U E FALSE 3. A static data member can be declared as public or private . TRUE F A L S E 4. A private non-static data member of a class may be accessed from any non-static method of that class. TRUE F A L S E 5. A local variable declared in one method may be accessed by all the methods beneath it in the same class. T R U E FALSE 6. Which of the following statements is true for the local variable temp as shown in the code fragment below? int i = 100; while(i > 0){ int temp = 0; i--; //rest of implementation hidden } [Note: zero or more options may be correct] a. temp may be accessed anywhere in that method. b. temp may only be accessed within the loop . c. temp is “destroyed” when the loop terminates 7/8. Bus and Engine are classes in the same package. Code fragments from each class are shown below. 1.00/1.001 Quiz 1

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 10

quiz1solutions - 1.00/1.001 Introduction to Computers and...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online