Computer Applications
Consider the following array and answer the questions given below:
int a[] = {12, 10, 8, 4, 6, 2, 3, 5, 7};
(a) What is the output of System.out.print(a[0] + a[5]);?
(b) What is the index (subscript) of the largest element of the array a[]?
Related Questions
(a) Name one String method which results in positive integer only.
(b) Name one String method which results in a character.
class area{ double area(double r, double h){ double l, a; a = 22.0 / 7 * r * l; l = Math.sqrt(r * r + h * h); return a; } }Specify the type of the error in the above program, correct and write the program to be error free.
(a) Write the Java statement to initialize the first 6 odd numbers in a 3 × 2 array.
(b) What is the result of x[0][1] + x[2][1] of the above array?
Give the output of the following program segment and specify how many times the loop is executed.
String s = "JAVA"; for(i = 0; i < s.length(); i += 2) System.out.println(s.substring(i));