Java Quiz

0 votes, 0 avg
167

Java Questions

1 / 15

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

2 / 15

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

            }

        }

3 / 15

3. Find the output of the following code.

        class bool_operator 

        {

            public static void main(String args[]) 

            {    

                 boolean a = true;

                 boolean b = !true;

                 boolean c = a | b;

     	     boolean d = a & b;

                 boolean e = d ? b : c;

                 System.out.println(d + " " + e);

            } 

        }

4 / 15

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

5 / 15

5. What is the function of javap command?

6 / 15

6. A method within a class is only accessible by classes that are defined within the same package as the class of the method. Which one of the following is used to enforce such restriction?

7 / 15

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

        class output 

        {

            public static void main(String args[])

            {

                String a = "hello i love java";

                System.out.println(a.indexOf('i')+" "+a.indexOf('o') +" "+a.lastIndexOf('i')+" "+a.lastIndexOf('o'));

            }

        }

8 / 15

8. How to format date from one form to another?

9 / 15

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

            }

        }

10 / 15

10. Which of these is an incorrect array declaration?

11 / 15

11. Which of these statements are incorrect?

12 / 15

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

13 / 15

13. Which of these method of Object class can clone an object?

14 / 15

14. Which of these keywords cannot be used for a class which has been declared final?

15 / 15

15. What is Recursion in Java?

Your score is

The average score is 35%

0%