Call
whatsapp
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
Cisco Training in Trivandrum, Trinity Technologies

No.1 Training Institute in Kerala

JAVA QUESTIONS : PART 27

Which of these is an incorrect Statement?

It is necessary to use new operator to initialize an array

Array can be initialized using comma separated expressions surrounded by curly braces

Array can be initialized when they are declared

None of the mentioned

SHOW ANSWER

Which of these is necessary to specify at time of array initialization?

Row

Column

Both Row and Column

None of the mentioned

SHOW ANSWER

What is the output of this program?
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++;
            }
        } 
    }
 

0 2 4 6 8

1 3 5 7 9

0 1 2 3 4 5 6 7 8 9

1 2 3 4 5 6 7 8 9 10

SHOW ANSWER

What is the output of this program?
class Multidimention_Array
    {
        public static void main(String args[])
        {
            int arr[][] = new int[3][];
            arr[0] = new int[1];
            arr[1] = new int[2];
            arr[2] = new int[3];               
        int sum = 0;
        for (int i = 0; i < 3; ++i) 
            for (int j = 0; j < i + 1; ++j)
                    arr[i][j] = j + 1;
        for (int i = 0; i < 3; ++i) 
            for (int j = 0; j < i + 1; ++j)
                    sum = sum+arr[i][j];
        System.out.print(sum);     
        } 
    }
 

11

10

13

14

SHOW ANSWER

What is the output of this program?
class Sample
    {
        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);
            } 
    }
 

3

0

6

1

SHOW ANSWER

What is the output of this program?
class Sample
    {
        public static void main(String args[]) 
        {
            char array_variable [] = new char[10];
        for (int i = 0; i < 10; ++i) 
            {
                array_variable[i] = 'i';
                System.out.print(array_variable[i] + "");
            }
        } 
    }
 

1 2 3 4 5 6 7 8 9 10

0 1 2 3 4 5 6 7 8 9 10

i j k l m n o p q r

i i i i i i i i i i

SHOW ANSWER

What is the output of this program?
class Sample
    {
        public static void main(String args[]) 
        {
            int array_variable[][] = {{ 1, 2, 3}, { 4 , 5, 6}, { 7, 8, 9}};
            int sum = 0;
            for (int i = 0; i < 3; ++i)
                for (int j = 0; j <  3 ; ++j)
                    sum = sum + array_variable[i][j];
            System.out.print(sum / 5);
        } 
    }
 

8

9

10

11

SHOW ANSWER

Which of these is an incorrect array declaration?

int arr[] = new int[5] ;

int [] arr = new int[5] ;

int arr[];

        arr=new int[5];

int arr[] = int[5] new ;

SHOW ANSWER

What will this code print?

int arr[] = new int [5];

          System.out.println(arr);

0

value stored in arr[0].

00000

Garbage value

SHOW ANSWER

What is the output of below snippet?
Object[] names = new String[3];
                 names[0] = new Integer(0);
 

ArrayIndexOutOfBoundsException

ArrayStoreException

Compilation Error

Code runs successfully

SHOW ANSWER

Can you make an array volatile?

True

False

SHOW ANSWER

Where is array stored in memory?

heap space

stack space

heap space and stack space

first generation memory

SHOW ANSWER

An array elements are always stored in ________ memory locations?

Sequential

Random

Sequential and Random

Binary search

SHOW ANSWER
BACK | NEXT
TRINITY SOFTWARE SOLUTIONS,IInd floor, Radheyam Towers, Gandhari Amman Kovil Road, Pulimood, Trivandrum - 1
0471-2334855 | 2335855 | 9447387064 | 9847003556 info@trinitytechnology.in