PreLab02-Ch2 - Name: Section Leader: Edward Leon Knapp...

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

View Full Document Right Arrow Icon
Name: Edward Leon Section Leader: Knapp Pre-Lab 02 – CSC 127A – Spring 2008 1. What's wrong with this code? int aNum = 20; aNum + 5 = aNum; In this code, the problem is that aNum was already declared. And although you can have the code output a function, it can not result in the previously declared value. Therefore, 5 cannot be added to aNum and have it result in aNum. 2. What is a constant? How do you declare a constant? A constant is a data item or value that when the program is executed, the data item or value will not change regardless of the rest of the program. 3. What happens if your program tries to divide an integer value by 0? For example: int num = 4 / 0; Java will not allow this function. It will still allow the program to compile, but when you run the program it will display a message and most likely stop the program. The displayed message is: Exception in thread “main” java.lang.ArithmeticException: / by Zero 4. Assume you have an int variable called num1 that has been declared and initialized. What does
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This lab report was uploaded on 04/18/2008 for the course CSC 127a taught by Professor Suzanne during the Spring '07 term at University of Arizona- Tucson.

Page1 / 2

PreLab02-Ch2 - Name: Section Leader: Edward Leon Knapp...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online