Java Quiz


Deprecated: round(): Passing null to parameter #1 ($num) of type int|float is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-content/plugins/quiz-maker/public/class-quiz-maker-public.php on line 1335

Deprecated: Implicit conversion from float 0.16666666666666666 to int loses precision in /home/u797631661/domains/codermantra.com/public_html/wp-content/plugins/quiz-maker/includes/class-quiz-maker-data.php on line 1008

Deprecated: Implicit conversion from float 0.16666666666666666 to int loses precision in /home/u797631661/domains/codermantra.com/public_html/wp-content/plugins/quiz-maker/includes/class-quiz-maker-data.php on line 1008

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/u797631661/domains/codermantra.com/public_html/wp-includes/formatting.php on line 449
0 votes, 0 avg
279

Java Questions

1 / 15

1. What is the syntax for java main method?

2 / 15

2. Find the output of the following 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++;

                }

            } 

        }

3 / 15

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

        class output 

        {

            public static void main(String args[])

            {

                 String chars[] = {"a", "b", "c", "a", "c"};

                 for (int i = 0; i < chars.length; ++i)

                     for (int j = i + 1; j < chars.length; ++j)

                         if(chars[i].compareTo(chars[j]) == 0)

                             System.out.print(chars[j]); 

            }

       }

4 / 15

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

5 / 15

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

6 / 15

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

        class static_out 

        {

            static int x;

     	static int y;

            void add(int a, int b)

            {

                x = a + b;

                y = x + b;

            }

        }    

        public class static_use 

        {

            public static void main(String args[])

            {

                static_out obj1 = new static_out();

                static_out obj2 = new static_out();   

                int a = 2;

                obj1.add(a, a + 1);

                obj2.add(5, a);

                System.out.println(obj1.x + " " + obj2.y);     

            }

       }

7 / 15

7. Which of these is returned by “greater than”, “less than” and “equal to” operators?

8 / 15

8. Which of these can be used to differentiate two or more methods having the same name?

9 / 15

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

        class recursion 

{

int func (int n)

{

int result;

if (n == 1)

return 1;

result = func (n - 1);

return result;

}

}

class Output

{

public static void main(String args[])

{

recursion obj = new recursion() ;

System.out.print(obj.func(5));

}

}


                            

10 / 15

10. What is an ineterface?

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. What will be the output of the following Java code?

        class Output 

        {

            public static void main(String args[]) 

            {

                Integer i = new Integer(257);  

                byte x = i.byteValue();

                System.out.print(x);

            }

        }

13 / 15

13. Which of the following is not an OOPS concept in Java?

14 / 15

14. What is Truncation in Java?

15 / 15

15. What is an assignment statement?

Your score is

The average score is 36%

0%