|(as it would appear on official course roster)|
|Umail address:||@umail.ucsb.edu|| section
4pm, 5pm or 6pm
| Optional: name you wish to be called|
if different from name above.
| Optional: name of "homework buddy"|
(leaving this blank signifies "I worked alone"
h00: HFJ 1,2: Java basics
|true||Mon 09/26 12:30PM||Wed 09/28 12:30PM|
You may collaborate on this homework with AT MOST one person, an optional "homework buddy".
MAY ONLY BE TURNED IN IN THE LECTURE/LAB LISTED ABOVE AS THE DUE DATE,
OR IF APPLICABLE, SUBMITTED ON GRADESCOPE. There is NO MAKEUP for missed assignments;
in place of that, we drop the three lowest scores (if you have zeros, those are the three lowest scores.)
Throughout the quarter, when I refer to HFJ, this means your Head First Java, 2nd Edition textbook.
- Please read and .
- If you don’t have your book yet, buy it! But in the meantime you can read this either at the UCSB library, or online.
- Visit the course wiki at http://foo.cs.ucsb.edu/56wiki and you’ll find the link to the online textbook.
- As you read, also consult the online reading notes. To find them, go to the online version of this homework, at /hwk/h00/ and click the links.
- Then, do the problems below.
- (10 pts) Please fill in the information at the top of this homework sheet, including your name and umail address. Put the time your discussion section starts (4pm, 5pm or 6pm) in the space indicated (the one you are registered for—even if you usually attend a different one.) If the other two items apply, please fill them in as well. Please do this every single time you submit homework for this class.
- (10 pts) If you didn't do it yet: For a variety of reasons, we will be using both github.ucsb.edu and github.com for this course. So, please, if you have not done it yet * create your github.com username and password (free account) at github.com * login once to github.ucsb.edu to establish your account (use your CSIL/ECI/CoE Unix account) * fill in the form at: http://bit.ly/cs56-f16-survey Points will be awarded if you do this by the time this homework is graded. If not, you'll still have to do it, but you wont get those points back.
- (10 pts) According to chapter two, anytime you need to test a class in Java, you need at least two classes. (As we'll discuss in lecture, this isn't strictly true, but let's go with it for now.) In the (oversimplified) view the author is presented (it is just chapter two, after all,) what are the two roles that these two classes are playing? Idenfity the roles, and explain each briefly,
- (10 pts) Throughout the book, some important material is sometimes in the little "side boxes" and dialogues. It's important to read everything on every page. One of these little side-boxes contains some important information about the "heap" in Java, and how it differs from the heap in C++. (C++ is not specifically mentioned, but from taking CS32, you should know about how the heap works in C++.) Briefly explain what the authors tell us about the heap in Java—something that is definitely different from the heap in C++.
- (10 pts) Explain briefly the relationships between/among (a) source code, (b) the Java Compiler, (c) Java bytecodes, and (d) JVM. You get full credit if you write a sentence (or a few sentences) that make it clear you understand how each of these relates to the big picture, and to the other three. To ensure full credit, *DO NOT JUST COPY TEXT FROM THE BOOK*. Put this in your own words. I should get at least a slightly different answer from each student (or pair of homework buddies.)
- (20 pts) On page 5 and 6, there is a set of exercises, and the answer to those. Here is a similar set of exercises, but the answer are not provided. Fill in the blanks.
java code explanation
boolean cs56IsAwesome= true;
Course c = new Course("CMPSC56","W16");
String thisQuarter = "F16";
- (20 pts) Now, the same kind of exercise, but in reverse---I give you the description, you give me the code. These are designed that you should be able to just reason them out from the examples of Java code given on p.4 and p.5, and your general programming background from CS16 and CS24 in C/C++---no other knowledge of Java should be needed.
java code explanation declare a variable that indicates whether this year is a leap year or not, and initialize it to say that it is not a leap year declare a variable item of type MenuItem, and initialize it to a "Caesar Salad" that costs 8.95. Assume those are the two parameters that the constructor takes. declare a variable of type double called total an assignment statement that calls the method getPrice on the variable item and adds the result into the variable total
- (10 pts) In Chapter 2, the author describes two different approaches to a problem—one taken by "Larry", and the other taken by "Brad". Based on what you read here, and in your own words, how would you characterize the main difference between the two approaches?