Easy Tutorial
For Competitive Exams

What is output of the following code:

public class solution{
        public static void main(String[] args){
                int[] x = {120, 200, 016 };
                for(int i = 0; i < x.length; i++)
                        System.out.print(x[i] + " ");
        }
}

120 200 16
120 200 14
120 200 016
016 is a compile error. It should be written as 16
Explanation:
016 is an octal number. The prefix 0 indicates that a number is in octal and in octal 16 is equal to 14.
Additional Questions

Choose the correct statement. Restriction on static methods are:
I. They can only call other static methods.
II. They must only access static data.
III. They cannot refer this or super in any way.

Answer

What is output of the following program:

public class solution{
        public static void main(String[] args){
                byte x = 127;
                x++;
                x++;
               System.out.println(x);
      }
}

Answer

Select the valid statement to declare and initialize an array.

Answer

What is the value of a[1] after the following code is executed?
int[] a = {0, 2, 4, 1, 3};
for(int i = 0; i < a.length; i++)
a[i] = a[(a[i] + 3) % a.length];

Answer

When you pass an array to a method, the method receives ________ .

Answer

What is output of the following code:

public class solution{
        public static void main(String[] args){
                int[] x = {120, 200, 016 };
                for(int i = 0; i < x.length; i++)
                        System.out.print(x[i] + " ");
        }
}

Answer

Choose the correct statement. Restriction on static methods are:
I. They can only call other static methods.
II. They must only access static data.
III. They cannot refer this or super in any way.

Answer

What is output of the following program:

public class solution{
        public static void main(String[] args){
                byte x = 127;
                x++;
                x++;
               System.out.println(x);
      }
}

Answer

Select the valid statement to declare and initialize an array.

Answer

What is the value of a[1] after the following code is executed?
int[] a = {0, 2, 4, 1, 3};
for(int i = 0; i < a.length; i++)
a[i] = a[(a[i] + 3) % a.length];

Answer
Share with Friends
Privacy Copyright Contact Us