Java Quiz

0 votes, 0 avg
383

Java Questions

1 / 15

1. 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);

            }

        }

2 / 15

2. Which of these is necessary condition for automatic type conversion in Java?

3 / 15

3. Choose the appropriate data type for this field: isSwimmer

4 / 15

4. Which data type value is returned by all transcendental math functions?

5 / 15

5. 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));

}

}


                            

6 / 15

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

        class recursion 

        {

            int func (int n) 

            {

                int result;

                result = func (n - 1);

                return result;

            }

        } 

        class Output 

        {

            public static void main(String args[]) 

            {

                recursion obj = new recursion() ;

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

            }

        }

7 / 15

7. Which of these is not a correct statement?

8 / 15

8. What is Truncation in Java?

9 / 15

9. Identify the modifier which cannot be used for constructor.

10 / 15

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

        class recursion 

        {

            int fact(int n) 

            {

                int result;

                if (n == 1)

                    return 1;

                result = fact(n - 1) * n;

                return result;

            }

        } 

        class Output 

        {

            public static void main(String args[]) 

            {

                recursion obj = new recursion() ;

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

            }

        }

11 / 15

11. Find the output of the following program.

class increment {
public static void main(String args[]) 
            {        
                 int g = 3;
                 System.out.print(++g * 8);
            } 
        }

12 / 15

12. Which of these is correct about passing an argument by call-by-value process?

13 / 15

13. Find the output of the following code.

        class output 

        {

            public static void main(String args[])

            { 

               StringBuffer s1 = new StringBuffer("Quiz");

               StringBuffer s2 = s1.reverse();

               System.out.println(s2);

            }

        }

14 / 15

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

        class A 

        {

            int i;

            public void display() 

            {

                System.out.println(i);

            }    

        }    

        class B extends A 

       {

            int j;

            public void display() 

            {

                System.out.println(j);

            } 

        }    

        class Dynamic_dispatch 

       {

            public static void main(String args[])

            {

                B obj2 = new B();

                obj2.i = 1;

                obj2.j = 2;

                A r;

                r = obj2;

                r.display();     

            }

       }

15 / 15

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

        class Output 

        {

            public static void main(String args[])

            {

                 Object obj = new Object();

    	     System.out.print(obj.getclass());

            }

        }

Your score is

The average score is 35%

0%

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