Chapter 3

Additional Web Questions

Please answer the following true or false questions:

 

1. Variables hold data.

 

2. In Java, variables are the same as fields.

 

3. A single variable can hold any type of data.

 

4. An int variable can hold the value of 10.

 

5. An int variable can hold the value of "ten".

 

6. Arrays can hold multiple values of different types.

 

7. A Vector can hold multiple values of different types.

 

8. A Vector can contain a variable of type float.

 

9. The index of the first element in an array is 1.

 

10. An array's size can be changed to hold more elements.

 

Answes:

 

1. true.

Variables are how programmers access and manipulate data.

 

2. true.

These two terms can, and usually are, used interchangeably.

 

3. false.

All variables have a given "type" when they are declared.  Each variable can only contain data of its given type.

 

4. true.

The integer 10 can be contained in a variable of type int.

 

5. false.

The value "ten" is a string and could only be contained in a variable of type String.

 

6. false.

Arrays can hold multiple values of the same type.

 

7. true.

A Vector can contain any number of Object-type values.

 

8. false.

The float type is one of the primitive types.  The Vector class cannot hold any values of the primitive type, only the Object-type.

 

9. false

Java is a zero-based language, meaning the index of the first element in an array or Vector is 0, not 1.

 

10. false.

An array's size is fixed once it is created.  A Vector's size can change, however.