Java Data Types, Variables and Arrays Mcqs

Our collections of Multiple choice questions and answers focuses on study of Java Data Types, Variables and Arrays . These questions are chosen from a collection of most authoritative and best reference books on Java Data Types, Variables and Arrays. Our aim is to prepare an individual for competitive exams like NTS, GAT, ECAT, University and College entrance exams and various tests and job interviews. One should practice our Mcqs to assimilate Data Types, Variables and Arrays comprehensively.

  1. Home
  2. »
  3. Languages
  4. »
  5. Programming Languages Mcqs
  6. »
  7. Java Programming Mcqs
  8. »
  9. Data Types Variables and Arrays...
  10. »
  11. Page 3

33.
What will this code print?

 int arr[] = new int [5];
    System.out.print(arr);

0

Value stored in arr[0].

00000

Class name@ hashcode in hexadecimal form

34.
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

36.
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

37.
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 + = arr[i][j];
     System.out.print(sum);  
        } 
    }

11

10

13

14

40.
What is the output of below snippet?

Object[] names = new String[3];
names[0] = new Integer(0);

ArrayIndexOutOfBoundsException

ArrayStoreException

Compilation Error

Code runs successfully

0Shares
0
Scroll to Top