Computer Science › Common Data Structures
Consider the following code:
public static void main(String\[\] args) {
double\[\]\[\] matrix = {{1,6,7},{1,4,5}};
graphics(matrix);
}
private static double graphics(double\[\]\[\] x) {
double r = 0;
for(int i = 0; i < x.length; i++) {
for(int j = 0; j < x\[i\].length; j++) {
r += x\[i\]\[j\] * (i + 1);
}
}
return r;
}
What is the return value for graphics in the code below:
double\[\]\[\] matrix = {{1,6,7},{1,4,5}};
graphics(matrix);
Consider the following code:
public static void main(String\[\] args) {
int\[\] vec = {8,-2,4,5,-8};
foo(vec);
}
private static void foo(int\[\] x) {
for(int i = 0; i < x.length; i++) {
int y = Math.abs(x\[i\]);
for(int j = 0; j < y; j++) {
System.out.print(x\[i\] + " ");
}
System.out.println();
}
}
Which of the following represents a possible output for the program above?
Which of the following blocks of code converts an array of characters into a string?
Which of the following blocks of code converts an array of characters into a string?
Consider the following code:
public static void main(String\[\] args) {
double\[\]\[\] matrix = {{1,6,7},{1,4,5}};
graphics(matrix);
}
private static double graphics(double\[\]\[\] x) {
double r = 0;
for(int i = 0; i < x.length; i++) {
for(int j = 0; j < x\[i\].length; j++) {
r += x\[i\]\[j\] * (i + 1);
}
}
return r;
}
What is the return value for graphics in the code below:
double\[\]\[\] matrix = {{1,6,7},{1,4,5}};
graphics(matrix);
Consider the following code:
public static void main(String\[\] args) {
int\[\] vec = {8,-2,4,5,-8};
foo(vec);
}
private static void foo(int\[\] x) {
for(int i = 0; i < x.length; i++) {
int y = Math.abs(x\[i\]);
for(int j = 0; j < y; j++) {
System.out.print(x\[i\] + " ");
}
System.out.println();
}
}
Which of the following represents a possible output for the program above?
On a standard binary tree, what would the data structure look like if we inserted the following names into the tree, supposing that names are compared in a standard lexicographic order:
Isaac, Henrietta, Nigel, Buford, Jethro, Cletus
On a standard binary tree, what would the data structure look like if we inserted the following names into the tree, supposing that names are compared in a standard lexicographic order:
Isaac, Henrietta, Nigel, Buford, Jethro, Cletus
Which of the following is NOT a difference between the Array class and the ArrayList class in Java?
Consider the following code:
int\[\] vals = {5,4,2};
String s = "Hervaeus";
String s2 = "";
for(int i = 0; i < s.length(); i++) {
for(int j = 0; j < vals\[i % vals.length\]; j++) {
s2 += s.charAt(i);
}
}
System.out.println(s2);
What is the output for the code above?