Java Reference
In-Depth Information
35.
Suppose that you have the following declarations:
int
[][] times =
new int
[30][7];
int
[][] speed =
new int
[15][7];
int
[][] trees =
new int
[100][7];
int
[][] students =
new int
[50][7];
a.
Write the definition of the method
print
that can be used to output
the contents of these arrays.
b.
Write the Java statements that call the method
print
to output the
contents of the arrays
times
,
speed
,
trees
, and
students
.
36.
What is the effect of the following statement?
Vector<Double> list =
new
Vector<Double>();
37.
Suppose that you have the following
Vector
object
list
:
list = ["One", "Two", "Three", "Four"];
What are the elements of
list
after the following statements execute?
list.addElement("Five");
list.insertElementAt("Six", 1);
38.
Suppose that you have the following
Vector
object
names
:
names = ["Gwen", "Donald", "Michael", "Peter", "Susan"];
What are the elements of
names
after the following statements execute?
names.removeElementAt(1);
names.removeElement("Peter");
39.
What is the output of the following program?
import
java.util.Vector;
9
public class
Exercise39
{
public static void
main(String[] arg)
{
Vector<String> strList =
new
Vector<String>();
Vector<Integer> intList =
new
Vector<Integer>();
strList.addElement("Hello");
intList.addElement(10);
strList.addElement("Happy");
intList.addElement(20);
strList.addElement("Sunny");
intList.addElement(30);
System.out.println("strList: " + strList);
System.out.println("intList: " + intList);
strList.insertElementAt("Joy", 2);
intList.removeElement(20);
Search WWH ::
Custom Search