lab and assignment 4 - CN104 CN003 II Computer Programming...

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

View Full Document Right Arrow Icon
CN104, CN003: 計算機程式設計 計算機程式設計 II, Computer Programming I LAB and Programming Assignments 4 Part A: Fill in the Blank 1. Every array has a(n) member that specifies the number of elements in the array. 2. When an argument is , a copy of the argument’s value is made and passed to the called method. 3. is a calling method that gives a called method the ability to access and potentially modify the caller’s data directly. 4. To pass an array to a method, you must specify the of the array as an argument in the method call. 5. An array may be an integer or an integer expression. 6. The first element in every array has index . 7. A(n) argument list is treated as an array within the method declaration’s body. 8. Arrays are entities—they remain the same length once they are created. 9. must be initialized before they are used and cannot be modified thereafter. 10. To pass one row of a two-dimensional array to a method that receives a one-dimensional array, you specify the array’s followed by only the . Part B: Exercises For each of the following problems, write a program or a program segment that performs the specified action. 1. Write the class declaration for class Square that has a private instance variable side of type double and a no-argument constructor that sets the side to 1.0 by calling a method named setSide that you will declare in Exercise 2 . 2. Write a method setSide for the class you defined in Exercise 1 . Set the side variable to the argument of the method. Also make sure that the side is not less than 0.0. If it is, that retrieves the value of instance variable side.
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 note was uploaded on 05/16/2010 for the course COMPUTER S WXES1110 taught by Professor Dr.liangng during the Spring '09 term at University of Malaya.

Page1 / 4

lab and assignment 4 - CN104 CN003 II Computer Programming...

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