CS10, 09S, UCSB
H09: (Based on Horstman, Chapters 7 and 8) Total points: ? (printable PDF)
Accepted: on paper, in lecture (1-1:50pm) on Monday, May 4th only.
No email submission allowed.
Name: (2 pts)______________________________ UCSBNetID (2 pts) _____________________
Section (4 pts) Circle one: Thu 4pm Fri 10am Fri 11am Fri noon
int?Character?int [] balances = {2000,-10,3000,-15,4000};
int overDrawnCount = 0;
for (int i=0; i<balances.length; i++)
{
if (balances[i] < 0)
overdrawnCount++;
}
Rewrite this section of code using the enhanced for loop from section 7.4 of the text.a.length |
Array |
a.length() |
Array list |
a.size |
String |
a.size() |
(none of the above) |
Please turn over for more problems
Movie class below compiles perfectly, but there is a problem with the constructor.public class Movie
{
private int year;
private String title;
/**
* Constructor for objects of class Movie
* @param theYear the year the movie was released
* @param theTitle the title of the movie
*/
public Movie(int theYear, String theTitle)
{
int year = theYear;
String title = theTitle;
}
/* ... Other methods would go here, but don't
concern yourself with that.
Just say what's wrong with the constructor. */
}