# Lecture20 - Java Programming 3e Concepts and Techniques Chapter 5 Arrays Loops and Layout Managers Using External Classes(II ICTN 2730/27/2008

This preview shows pages 1–10. Sign up to view the full content.

Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes (II) ICTN 2730 Lecture 20 02/27/2008

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

View Full Document
Chapter 4: Decision Making and Repetition with Reusable Objects 2 Assignments Read chapter 5 and lecture notes. Homework 5 sample solutions have been posted. Homework 6 is due tonight. Make sure you understand Homework 5 before doing Homework 6. Consider completing the bonus section if you would like to improve the final grade.
Chapter 4: Decision Making and Repetition with Reusable Objects 3 Quiz 02 Evaluate the following expression: 2*7/3+4+Math.pow(5,2) 33.0 (Correct answer) 33 33.66 33.7 Check pages 16-18 in lecture18.ppt. We need to learn from the homework. Please check the sample solutions.

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

View Full Document
Chapter 4: Decision Making and Repetition with Reusable Objects 4 Quiz 02 2*7/3 = 4 The remainder is dropped. Check Integer Division on Page 151. Math.pow(5,2) = 25.0 //Double value 2*7/3+4+Math.pow(5,2) = 4+4+ 25.0 = 33.0 //Result is double, 33.0 != 33 When int values are mixed with double values in an expression, Java stores the answer as the larger data type (double). Declare the data type of the result as int will result in an error “possible loss of precision”. Why do we care?
Chapter 4: Decision Making and Repetition with Reusable Objects 5 Quiz 02 int a=7; int b=10; boolean c=(a<b)||(a==b); What is the value of c? (a < b)==true (a==b)==false true || false == true The value of c is true Check page 236 for logical operators

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

View Full Document
Chapter 4: Decision Making and Repetition with Reusable Objects 6 Quiz 02 public float TaxWithheld(float income, float withheldRate) { float withheld; withheld=income*withheldRate; return withheld; } The variable income is a parameter .
Chapter 4: Decision Making and Repetition with Reusable Objects 7 Quiz 02 System.out.println("It"+"is"+"a"+"good"+"d ay!"); What will the output look like? Itisagoodday! (Correct answer) It is a good day! (Wrong) How to join strings, numbers using the plus sign?

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

View Full Document
Chapter 4: Decision Making and Repetition with Reusable Objects 8 Quiz 02 public float TaxWithheld(float income , float withheldRate) { float withheld; withheld=income*withheldRate; return withheld; } In the main method, the TaxWithheld() method above is called by the following statement: result=TaxWithheld( salary , rate); //call method What is the data type of salary? Answer: float What is the return type of the method? Answer: float Arguments and parameters for a called method and the calling statement must be of the same number, order, and data type
Chapter 4: Decision Making and Repetition with Reusable Objects 9 Quiz 02 Which of the following statements can be used to display text in an applet? outputlabel.setText("Welcome");

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/29/2008 for the course ICTN 2730 taught by Professor Li during the Spring '08 term at East Carolina University .

### Page1 / 34

Lecture20 - Java Programming 3e Concepts and Techniques Chapter 5 Arrays Loops and Layout Managers Using External Classes(II ICTN 2730/27/2008

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

View Full Document
Ask a homework question - tutors are online