Home  | 

 

ONLINE SESSION C

 

In 2 parts: chapter seven review & exam one review

 

Chapter Seven Review

Solve both of the following problem statements covering chapter seven material. These are NOT  challenges in the textbook.                           

SEND THEM TO THE GRADER   NOT DR. GUYNES

by Wednesday March 20 which is the day after the 1st exam

 

 

 

#1    Write  a simple array program that:    Des not use an “external class & demo      program"    [If you wish, you may break it down into methods, but that is NOT         required.]

 

   a.     Set up 4 arrays which each hold 6 employee’s data:

             int[ ] empid

             int[ ] hours

             double[ ] rate

             double[ ] wages

     

   b.     Set up loops to load the empid, hours and rate arrays 

 

   c.     Set up a loop to calculate values for the wages array.

TAKE OVERTIME [hours > 40],  INTO CONSIDERATION, 

thru the use  of the IF statement

[overtime  is time and a half as usual]

 

   d.     Set up a loop to print  the empid and wages for each employee

 

 

#2        Write an ArrayList program that:

 

   a.    Creates a list of 5 automobile names that you make up and then retrieves those             5 names and displays all of them.

 

   b.    Adds Mercedes at position 3 of the array and then retrieves the  names and          displays all of them.

 

   c.     Replaces the fourth car with a BMW and then retrieves the  names and displays             all of them.

 

   d.    Removes the second car and then retrieves the  names and displays all of them.

 

 

 

EXAM ONE REVIEW

exam is tuesday march 19

covering CH 4 [If's and loops] , CH 5 [Methods], CH 6 [Classes], CH 7 [Arrays]  

After you Review/Read the above chapters again

BRIEFLY DISCUSS THE FOLLOWING TERMS AND CONCEPTS AND

THEN EMAIL YOUR  definition terms  answers TO DR. GUYNES

by Sunday Midnight March 17th - I will look them over and log them in

JAVA TERMS:

Classes/Methods

Void/Value returning

Parameter lists/Argument lists

Instance fields

Constructors

Overloading

Mutators/Accessors

Arrays/Subscripts

Arraylist

MAINFRAME TERMS:

 PDS

Members

HILITE ON

How did you edit files on the System Z - inserting, copying, deleting from Problem One

How did you use FTP

How did you run jobs on the system Z

Where did you put the input data on the Z

Where did you put the Cobol  programs on the Z

Where did the output report go on the Z

If the job did not run, how did you get to the job queue

Discuss all the steps required to run the 6 C++ jobs that you ran on the System Z

 

 

 

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

                    The following multiple choice questions are for your review only - you DO NOTsend me the answers     [they are at the endof the MC questions]

 

 

Multiple Choice  ch 4

1.    What will the println statement in the following program segment display?

int x = 5;

System.out.println(x++);

a.    5

b.    6

c.    0

d.    None of these

 

 

2.    What will the println statement in the following program segment display?

int x = 5;

System.out.println(++x);

a.    5

b.    6

c.    0

d.    None of these

 

3.    In the expression number++, the ++ operator is in what mode?

a.    prefix

b.    pretest

c.    postfix

d.    posttest

 

4.    What is each repetition of a loop known as?

a.    cycle

b.    revolution

c.    orbit

d.    iteration

 

5.    This is a variable that controls the number of iterations performed by a loop.

a.    loop control variable

b.    accumulator

c.    iteration register variable

d.    repetition meter

 

6.    The while loop is this type of loop.

a.    pretest

b.    posttest

c.    prefix

d.    postfix

 

7.    The do-while loop is this type of loop.

a.    pretest

b.    posttest

c.    prefix

d.    postfix

 

8.    The for loop is this type of loop.

a.    pretest

b.    posttest

c.    prefix

d.    postfix

 

9.    This type of loop has no way of ending and repeats until the program is interrupted.

a.    indeterminate

b.    interminable

c.    infinite

d.    timeless

 

10. This type of loop always executes at least once.

a.    while

b.    do-while

c.    for

d.    any of these

 

11. This expression is executed by the for loop only once, regardless of the number of iterations.

a.    initialization expression

b.    test expression

c.    update expression

d.    pre-increment expression


 

12. This is a variable that keeps a running total.

a.    sentinel

b.    sum

c.    total

d.    accumulator

 

13. This is a special value that signals when there are no more items from a list of items to be processed. This value cannot be mistaken as an item from the list.

a.    sentinel

b.    flag

c.    signal

d.    accumulator

 

 

 

Multiple Choice ch 5

 

1.    This type of method does not return a value.

a.    null

b.    void

c.    empty

d.    anonymous

2.    This appears at the beginning of a method definition.

a.    semicolon

b.    parentheses

c.    body

d.    header

3.    The body of a method is enclosed in      .

a.    curly braces { }

b.    square brackets []

c.    parentheses ()

d.    quotation marks ""

4.    A method header can contain      .

a.    method modifiers

b.    the method return type

c.    the method name

d.    a list of parameter declarations

e.    all of these

f.     none of these

5.    A value that is passed into a method when it is called is known as a(n)      .

a.    parameter

b.    argument

c.    signal

d.    return value

6.    A variable that receives a value that is passed into a method is known as a(n)      .

a.    parameter

b.    argument

c.    signal

d.    return value

7.    This javadoc tag is used to document a parameter variable.

a.    @parameter

b.    @param

c.    @paramvar

d.    @arg


8.    This statement causes a method to end and sends a value back to the statement that called the method.

a.    end

b.    send

c.    exit

d.    return

 


 

Multiple Choice  ch 6

  1. This is a collection of programming statements that specify the fields and methods that a particular type of object may have.
    1. class
    2. method
    3. parameter
    4. instance
  2. A class is analogous to a(n)       .
    1. house
    2. blueprint
    3. drafting table
    4. architect
  1. An object is a(n)       .
    1. blueprint
    2. primitive data type
    3. variable
    4. instance of a class
  1. This is a class member that holds data.
    1. method
    2. instance
    3. field
    4. constructor
  1. This key word causes an object to be created in memory.
    1. create
    2. new
    3. object
    4. construct
  1. This is a method that gets a value from a class’s field, but does not change it.
    1. accessor
    2. constructor
    3. void
    4. mutator
  1. This is a method that stores a value in a field or in some other way changes the value of a field.
    1. accessor
    2. constructor
    3. void
    4. mutator
  1. When the value of an item is dependent on other data, and that item is not updated when the other data is changed, what has the value become?
    1. bitter
    2. stale
    3. asynchronous
    4. moldy

 

  1.  

This is a method that is automatically called when an instance of a class is created.

    1. accessor
    2. constructor
    3. void
    4. mutator
  1. When a local variable has the same name as a field, the local variable’s name does this to the field’s name.
    1. shadows
    2. complements
    3. deletes
    4. merges with
  1. This is automatically provided for a class if you do not write one yourself.
    1. accessor method
    2. default instance
    3. default constructor
    4. variable declaration
  1. Two or more methods in a class may have the same name, as long as this is different.
    1. their return values
    2. their access specifier
    3. their parameter lists
    4. their memory address
  1. The process of matching a method call with the correct method is known as       .
    1. matching
    2. binding
    3. linking
    4. connecting
  1. A class’s responsibilities are       .
    1. the objects created from the class
    2. things the class knows
    3. actions the class performs
    4. both b and c

 


 

Multiple Choice  ch 7

  1. In an array declaration, this indicates the number of elements that the array will have.
    1. subscript
    2. size declarator
    3. element sum
    4. reference variable
  2. Each element of an array is accessed by a number known as a(n)      .
    1. subscript
    2. size declarator
    3. address
    4. specifier
  1. The first subscript in an array is always      _.
    1. 1
    2. 0
    3. -1
    4. 1 less than the number of elements
  1. The last subscript in an array is always      .
    1. 100
    2. 0
    3. -1
    4. 1 less than the number of elements
  1. Array bounds checking happens      .
    1. when the program is compiled
    2. when the program is saved
    3. when the program runs
    4. when the program is loaded into memory
  1. This array field holds the number of elements that the array has.
    1. size
    2. elements
    3. length
    4. width
  1. To insert an item at a specific location in an ArrayList object, you use this method.
    1. store
    2. insert
    3. add
    4. get
  1. To delete an item from an ArrayList object, you use this method.
    1. remove
    2. delete
    3. erase
    4. get

 

  1. To determine the number of items stored in an ArrayList object, you use this method.
    1. size
    2. capacity
    3. items
    4. length

 

 

                    

 

 

 ANSWERS TO MC

             

 

Chapter 4

Multiple Choice

 

1. a

2. b

3. c

4. d

5. a

6. a

7. b

8. a

9. c

10. b

11. a

12. d

13. a

 

Chapter 5

Multiple Choice

 

1. b

2. d

3. a

4. e

5. b

6. a

7. b

8. d

 


 

Chapter 6

Multiple Choice

1.         a

2.         b

3.         d

4.         c

5.         b

6.         a

7.         d

8.         b

9.         b

10.       a

11.       c

12.       c

13.       b

14.       d

 

 

 

 

Chapter 7

Multiple Choice

 

1. b

2. a

3. b

4. d

5. c

6. c

7. c

8. a

9. a