Question

C# 1.) Assume an integer array named bArray was dimensioned to store 10 rows and 2...

C#

1.) Assume an integer array named bArray was dimensioned to store 10 rows and 2 columns. Use a variable named element to reference individual cells. Fill in the blanks below for the foreach loop which might be used to display the contents of the array.
foreach(Blank 1, Blank 2, Blank 3, Blank 4) .

2.) In order to place a new element in an ArrayList use the ___________ method.

3.)

With the following declaration:
int [ , ] ctn = {{30, 10, 20, 40, 60},
{55, 70, 90, 20, 10}};
the statement Write(“Result = “ + (cnt[0, 2] + cnt[1, 3])); will display

a

Result = 2020

b

Result = 40

c

Result = "cnt[0, 2] + cnt[1, 3]"

d

Result = 1090

e

none of the above

4.)

When you pass an element from an ArrayList to a method, the method receives:

a

a copy of the full ArrayList

b

the address of the first element in the ArrayList

c

a copy of the value of that element stored in the ArrayList

d

the address of that element in the ArrayList

e

none of the above

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer 1:
foreach(int i in element) .
Answer 2: insert method

Answer 3: Result 2020

0,2 we have 20
1,3 we have 20
Answer 4:a copy of the value of that element stored in the ArrayList


as we are passing only single value not the entire list

Add a comment
Know the answer?
Add Answer to:
C# 1.) Assume an integer array named bArray was dimensioned to store 10 rows and 2...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • QUESTION 1 Using the following declarations and a member of the Array class, int [ ]...

    QUESTION 1 Using the following declarations and a member of the Array class, int [ ] bArray = new int [10]; int location; Using a method in the Array class, write a statement that would change the order of the elements in the bArray array. The contents of the first cell should hold what was in the last cell. The second cell should hold what was in the next to last cell. __________________________ HINT: You must write the full statement...

  • 1.The following statement gets an element from position 4 in an array named myArray: x =...

    1.The following statement gets an element from position 4 in an array named myArray: x = myArray[4]; What is the equivalent operation using an array list named list.? A x = list.get(); B x = list.get(4); C x = list.get[4]; D x = list[4]; 2.Consider the following code snippet: ArrayList<Integer> num1 = new ArrayList<Integer>(); int data; Scanner in = new Scanner(System.in); for (int i = 0; i < 5; i++) { data = in.nextInt(); num1.add(data); if (data == 0 &&...

  • 1. Write a C function named find that receives a one-dimensional array of type integer named...

    1. Write a C function named find that receives a one-dimensional array of type integer named arr and its size of type integer. The function fills the array with values that are the power of four (4^n) where n is the index. After that, the function must select a random index from the array and move the array elements around the element stored in the randomly selected index Example arr = [1, 4, 16, 64, 256) if the randomly selected...

  • Write a static method named sumOf that takes an array of int values as an argument...

    Write a static method named sumOf that takes an array of int values as an argument (you may safely assume that the array contains at least 1 element). This method should return the sum of all values in the array. Examples: Given the following array declaration and definition. int[] theArray = {0, 0, 0, 0, 0, 0}; sumOf(theArray) will return 0 Given the following array declaration and definition. int[] theArray = {1, 1, 1, 1, 1, 1}; sumOf(theArray) will return...

  • *Java* Hi. I need some help with creating generic methods in Java. Write a program GenMethods...

    *Java* Hi. I need some help with creating generic methods in Java. Write a program GenMethods that has the following generic methods: (1) Write the following method that returns a new ArrayList. The new list contains the nonduplicate (i.e., distinct) elements from the original list. public static ArrayList removeDuplicates(ArrayList list) (2) Write the following method that shuffles an ArrayList. It should do this specifically by swapping two indexes determined by the use of the random class (use Random rand =...

  • Write you code in a class named HighScores, in file named HighScores.java. Write a program that...

    Write you code in a class named HighScores, in file named HighScores.java. Write a program that records high-score data for a fictitious game. The program will ask the user to enter five names, and five scores. It will store the data in memory, and print it back out sorted by score. The output from your program should look approximately like this: Enter the name for score #1: Suzy Enter the score for score #1: 600 Enter the name for score...

  • this language is JAVA 2. Design a class named Location for locating a maximum value and...

    this language is JAVA 2. Design a class named Location for locating a maximum value and its location in a two-dimensional array. The class contains public data fields row, column, and maxValue that store the maximal value and its indices in a two-dimensional array with row and column as int types and maxValue as a double type. Write the following method that returns the location of the largest element in a two-dimensional array: Public static Location locateLargest(double [][] a) Create...

  • Write a method named printGrid that accepts two integer parameters rows and cols. The output is...

    Write a method named printGrid that accepts two integer parameters rows and cols. The output is a comma-separated grid of numbers where the first parameter (rows) represents the number of rows of the grid and the second parameter (cols) represents the number of columns. The numbers count up from 1 to (rows x cols). The output are displayed in column-major order, meaning that the numbers shown increase sequentially down each column and wrap to the top of the next column...

  • a) (C language) Let’s consider an integer array of size 10. (10 marks, each part is...

    a) (C language) Let’s consider an integer array of size 10. (10 marks, each part is 2 marks) int a[10]; I. How would you assign a pointer, called pA, to store the address of element 0 of this array? Write the C code for your answer. II. Using pA, how would you obtain the value of the next element (element 1) of the array? III. Explain in 2-3 sentences what the statement pA = a[1]; would do. IV. Is the...

  • Write a method named printGrid that accepts two integer parameters rows and cols. The output is...

    Write a method named printGrid that accepts two integer parameters rows and cols. The output is a comma-separated grid of numbers where the first parameter (rows) represents the number of rows of the grid and the second parameter (cols) represents the number of columns. The numbers count up from 1 to (rows x cols). The output are displayed in column-major order, meaning that the numbers shown increase sequentially down each column and wrap to the top of the next column...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT