Problem #1 Describe the common error in the following code. Arrays may be instan
ID: 3686855 • Letter: P
Question
Problem #1 Describe the common error in the following code.
Arrays may be instance variables as follows:
private int[ ] scores;
The scores are read-only from outside the class; therefore, we will provide a getter method but no setter method as follows:
public int[ ] getScores() {
return scores;
} // end of getScores
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Problem #3 Consider a table as a multidimensional array. Write an equals method that determines if two tables are equal.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Problem #7 What is the last index of the array a below? What is the value of a.length?
int[ ] a = new int[10];
Explanation / Answer
1.This is the correction to be made:
public int *getScores() {
return scores;
}
we cannot return an array unless the function is a pointer pointing to the array elements.This is what ive done and now this will return the entire array scores.
3.
a.length will give the length of the array which is 10
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.