M/F 2:303:20 
CS 1130: Transition to OO Programming Spring 2016 

Main
About: Overview Announcements Staff Consultants Calendar Materials: Texts DrJava Terminology Lectures: InClass WebBased VideoNote Assessment: Grading Assignments Labs Resources: CMS Piazza (link) Piazza (about) Java API Style Guide Academic Integrity 
Java ExpressionsThere is a PDF version of these instructions, if you would prefer to have that instead. This lab serves two purposes. First, it is designed to get you started with DrJava immediately. Second, gives you hands on experience with Java expressions, which we talked about on the first day of class. With that said, you are not expected to be be writing any programs for this lab; for the most part you will just be using DrJava as a glorified calculator. Getting Started with DrJavaTo open DrJava in a ACCELlab computer, find the following folder: Start ⇒ All programs ⇒ Class Files ⇒ DrJava Inside the DrJava folder will be a .jar file; double click on this file to start DrJava. If your primary computer is a laptop, bring it to the lab as it is an excellent opportunity to get started with DrJava on your machine. Follow the instructions on the DrJava page. Feel free to ask a consultant for help if you run into problems; that is why they are there. Lab Instructions
Below is a list of expressions. For each expression, we would like you to first compute
the expression in your head, without DrJava. You should write down what you think the
value is in the second column of the table. If you have no idea, you should write "?".
Once you have done that, you should then use DrJava to compute the same expression. Simply
cut and past the expression from this webpage into the Interactions pane, and hit the
If the two values are different, you should try to figure out why DrJava gave the answer that it did. Come up with a reasonable explanation and put it in the final column. You are not really being graded on these labs (see Turning In the Lab), so you should just make your best guess at what is happening; your answer will help the instructor and consultants understand how to better aid you. As part of this lab, you may find it convenient to enlarge the Interactions pane. To do this, put the mouse on the horizontal bar running across the entire window, hold down the mouse button, and drag the bar upwards. Also, you can use the uparrow key to obtain a previous expression; then you can edit the expression and hit the return key to have the modified expression evaluated. As this is the first lab, it is a little shorter than some of the future labs. With that said, do not waste time! If you don't understand something, ask your lab instructor or a consultant immediately. It is very important that you understand how each expression is evaluated, so if an answer doesn't make sense, ask someone. The lab instructors and consultants are in the lab to help. They will look over your shoulder from time to time and give you advice. Turning in the LabLabs are graded on effort, not correctness. When you are finished, you should show your written answers to this lab to your lab instructor, who will record that you did it. If you do not finish during the lab, finish it within the next few days and show it to your lab instructor next week. Because the lab is graded on effort, you should focus all of your efforts on understanding and not just getting the answers correct. The primary purpose of thes labs is for you to have a handson session during which the consultants and instructors can help you out. Lab ProblemsINT Expressions
DOUBLE Expressions
It is important that you understand why an addition like Double.MIN_VALUE + 1 equals 1. Here is the explanation: In Java, the mantissa in "mantissa E exponent" can only hold a certain maximum number of digits. As a simple example, suppose that the mantissa in Java can have only 3 digits (it can actually have more, but the argument does not really change). Both 3.24E5 and 32.4E5 can be stored in a double in this hypothetical version of Java, but not 32.46E5; the latter number contains 4 digits in the mantissa. Using this restriction in this hypothetical version of Java, add up the two numbers 1.0E0 and 3.20E2. 1 + 0.032 = 1.032 = 1.032E0, right? But in our imaginary version of Java, where the mantissa can only hold 3 digits, the 2 would be dropped and Java will return 1.03E0. In essence, the least significant digits are simply removed. Now, using the same restriction, YOU add up the two numbers 1.00E0 and 1.00E4. What do you (as a nonJava processing human) get for the answer? Now, what would the hypothetical Java — which is limited to a mantissa with only 3 digits — return for the answer? This example should show you why Double.MIN_VALUE + 1 equals 1. Casting Expressions
Given the results in the table above, answer the following question: which operator
has higher precedence, casting or division? Explain your answer:
BOOLEAN Expressions
For the last two expressions in the table above, answer the following question:
why does the last expression in the table not work but the one above it does?
String Expressions
Given the results in the table above, answer the following question: what does + do if at
least one operand is a String?
