Computer Applications
Which of the following is a valid array declaration statement to store the Gender of 80 employees [ 'M'-male, 'F'-female, 'T'-transgender ]?
- char gender = new char[80];
- char gender[] = new char[80];
- char gender[80];
- char gender[80] = new char[ ];
Java Arrays
3 Likes
Answer
char gender[] = new char[80];
Reason — In Java, arrays must be declared with the type followed by square brackets [] either before or after the variable name. The correct syntax to declare a character array of size 80 is char gender[] = new char[80];.
Answered By
3 Likes
Related Questions
The method to convert a String to double is:
- String.toDouble()
- Double.Parsedouble()
- Double.parseDouble(String)
- Double.parseDouble()
The java statement System.out.println(x[x.length]) results in:
- logical error
- syntax error
- run time error
- no error
Arrange the following java statements in the correct order of execution to accept values into the array a[]:
(i) a[i]=sc.nextInt( );
(ii) int a[]=new int[10];
(iii) Scanner sc=new Scanner(System.in);
(iv) for(i=0;i<10;i++)- (i), (ii), (iii), (iv)
- (ii), (iii), (iv), (i)
- (iv), (iii), (ii), (i)
- (iii), (i), (iv), (ii)
In the bubble sort technique, during each iteration of the inner loop, two adjacent elements are …………… and …………… .
(i) compared
(ii) swapped
(iii) selected
(iv) deleted- (i) and (ii)
- (ii) and (iii)
- (iii) and (iv)
- (ii) and (iv)