midterm2Solution

midterm2Solution - ENGR 131 Fall 2007 Midterm #2 Name:...

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

View Full Document Right Arrow Icon
ENGR 131 Fall 2007 Midterm #2 Name: Solution CWRU Network ID: Lab Section (circle one): W 2:00pm W 3:00pm R 10:00am F 11:30am Directions: You have 75 minutes for 5 problems. You may not use books, notes or any other course related mate- rials. A Java reference sheet is attached for your use. You may not use computers, calculators or any other electronic devices. Do all your work on this test paper. Only one attempt at a problem will be accepted. If you make several attempts, you must indicate which one you want counted. Use your time wisely. Work quickly but accurately, come back to those problems you cannot immediately solve. Problem Points 1 2 3 4 5 Total
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. (20 points) ( Evaluate Java Expressions. ) Evaluate the following Java expressions and write their values in the box pro- vided. You may use the area outside of the boxes for calculations. Example: 4 >= 3 true Assume the following declarations/initializations have been made: int[] list = {1, -1, 1, -1, 1, -1, 1, -1}; char[][] table = {{‘a’, ‘b’, ‘c’}, {‘d’, ‘e’, ‘f’}}; String s = ‘‘Happy Thanksgiving!’’; int len = s.length(); 1. list.length 8 2. list[6] 1 3. table.length 2 4. table[0].length 3 5. table[1][1] ‘e’ 6. s.charAt(0) ‘H’ 7. s.replaceAll(‘‘a’’, ‘‘A’’) ‘‘HAppy ThAnksgiving!’’ 8. s.indexOf(‘‘Thanks’’) 6 9. len 19 10. s.substring((len - 7), len) ‘‘giving!’’ 2
Background image of page 2
Problem 2. (24 points) (
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 / 8

midterm2Solution - ENGR 131 Fall 2007 Midterm #2 Name:...

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