Computer Applications
Which of the following is a valid way to declare and initialize an integer array to store the ages of 50 students?
Related Questions
Define a class to accept values into 4x4 array and find and display the sum of each row.
Example:
A[][]={{1,2,3,4},{5,6,7,8},{1,3,5,7},{2,5,3,1}}
Output:
sum of row 1 = 10 (1+2+3+4) sum of row 2 = 26 (5+6+7+8) sum of row 3 = 16 (1+3+5+7) sum of row 4 = 11 (2+5+3+1)
A class teacher wants to arrange the names of her students in alphabetical order. Define a class NameSorter that stores the given names in a one-dimensional array. Sort the names in alphabetical order using Bubble Sort technique only and display the sorted names.
Aryan, Zoya, Ishaan, Neha, Rohan, Tanya, Manav, Simran, Kabir, Pooja
public class NameSorter { void bubbleSort(String names[]) { int len = names.length; _______(1)_________ { _______(2)_________ { _______(3)_________ { String t = names[j]; _______(4)_________ _______(5)_________ } } } } public static void main(String[] args) { String arr[] = {"Aryan", "Zoya", "Ishaan", "Neha", "Rohan", "Tanya", "Manav", "Simran", "Kabir", "Pooja" }; NameSorter obj = new NameSorter(); obj.bubbleSort(arr); for (int i = 0; i < arr.length; i++) { System.out.println(arr[i]); } } }
Define a class to accept values into an integer array of order 4 x 4 and check whether it is a DIAGONAL array or not. An array is DIAGONAL if the sum of the left diagonal elements equals the sum of the right diagonal elements. Print the appropriate message.
Example:
3 4 2 5
2 5 2 3
5 3 2 7
1 3 7 1Sum of the left diagonal element = 3 + 5 + 2 + 1 = 11
Sum of the right diagonal element = 5 + 2 + 3 + 1 = 11
A single dimensional array contains 37 elements. Which of the following represents the index of its second-to-last element.