0% found this document useful (0 votes)
20 views1 page

0 - Javamcq Part1 36

The document provides example Java code snippets and questions about arrays. It contains three code examples showing array initialization and accessing elements. The correct outputs are provided for multiple choice questions about manipulating and accessing values in arrays.

Uploaded by

Priyansh Gangani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

0 - Javamcq Part1 36

The document provides example Java code snippets and questions about arrays. It contains three code examples showing array initialization and accessing elements. The correct outputs are provided for multiple choice questions about manipulating and accessing values in arrays.

Uploaded by

Priyansh Gangani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

33-which of these is necessary to specify at time of array initialization?

a) row
b) column
c) both row and column
d) none of the mentioned
answer: a
34-what will be the output of the following java code?

Class array_output
{
public static void main(String args[])
{
int array_variable [] = new int[10];
for (int i = 0; i < 10; ++i)
{
array_variable[i] = i;
system.out.print(array_variable[i] + " ");
i++;
}
}
}
a) 0 2 4 6 8
b) 1 3 5 7 9
c) 0 1 2 3 4 5 6 7 8 9
d) 1 2 3 4 5 6 7 8 9 10
ans: a
35-what will be the output of the following java code?
Class evaluate
{
public static void main(String args[])
{
int arr[] = new int[] {0 , 1, 2, 3, 4, 5, 6, 7, 8, 9};
int n = 6;
n = arr[arr[n] / 2];
system.out.println(arr[n] / 2);
}
}
a) 3
b) 0
c) 6
d) 1
ans: d
36-what will be the output of the following java code?
Class array_output
{
public static void main(String args[])
{
char array_variable [] = new char[10];
for (int i = 0; i < 10; ++i)
{

You might also like