Java Quiz

0 votes, 0 avg
377

Java Questions

1 / 15

1. Which statement provides an easy way to dispatch execution to different parts of your code based on the value of an expression?

2 / 15

2. Find the output of the following code.

Public class Solution{
         Public static void main(String args[]){
                 Int i;
                 for(i = 1; i < 6; i++){ 
                     if(i > 3) continue;
                 }
                 System.out.println(i);
          }
}

3 / 15

3. What is not the use of “this” keyword in Java?

4 / 15

4. Find the output of the following program.

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

5 / 15

5. Find the output of the following program.

public class Solution{
       public static void main(String[] args){
                     short x = 10;
                     x =  x * 5;
                     System.out.print(x);
       }
}

6 / 15

6. What is an assignment statement?

7 / 15

7. Which of these is not a correct statement?

8 / 15

8. How is Date stored in database?

9 / 15

9. Find the output of the following code.

        class ternary_operator 

        {

            public static void main(String args[]) 

            {        

                 int x = 3;

                 int y = ~ x;

                 int z;

                 z = x > y ? x : y;

                 System.out.print(z);

            } 

        }

10 / 15

10. Which of these is correct way of calling a constructor having no parameters, of superclass A by subclass B?

11 / 15

11. What will be the output of the following Java code?

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); 	
        } 
    }

12 / 15

12. Which of these data types is used to store command line arguments?

13 / 15

13. Which of these keywords is used to prevent content of a variable from being modified?

14 / 15

14. What will be the output of the following Java program?

        class Output 

        {

             public static void main(String args[]) 

            {

                double x = 2.0;  

                double y = 3.0;

                double z = Math.pow( x, y );

                System.out.print(z);

            }

        }

15 / 15

15. Find the output of the following code.

        class box 

        {

            int width;

            int height;

            int length;

        } 

        class main

        {

            public static void main(String args[]) 

            {        

                 box obj = new box();

                 obj.width = 10;

                 obj.height = 2;

                 obj.length = 10;

                 int y = obj.width * obj.height * obj.length; 

                 System.out.print(y);

            } 

        }

Your score is

The average score is 35%

0%

Written by Shubhranshu Shekhar, who has trained 20000+ students in coding.