Java Quiz

0 votes, 0 avg
416

Java Questions

1 / 15

1. Where does the system stores parameters and local variables whenever a method is invoked?

2 / 15

2. Which of the following is true about public access modifier?

3 / 15

3. 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?

4 / 15

4. File class is included in which package?

5 / 15

5.  Which variables are created when an object is created with the use of the keyword 'new' and destroyed when the object is destroyed?

6 / 15

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

7 / 15

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

    class abc

    {

        public static void main(String args[])

        {

            if(args.length>0)

            System.out.println(args.length);

        }

    }

8 / 15

8. Which of the following are not java modifiers?

9 / 15

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

        class String_demo 

        {

            public static void main(String args[])

            {

                int ascii[] = { 65, 66, 67, 68};

                String s = new String(ascii, 1, 3);

                System.out.println(s);

            }

       }

10 / 15

10. What does Object Oriented Programming means?

11 / 15

11. Which of these jump statements can skip processing the remainder of the code in its body for a particular iteration?

12 / 15

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

            } 

        }

13 / 15

13. What is the function of javap command?

14 / 15

14. 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++;

                }

            } 

        }

15 / 15

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

            }

        }

Your score is

The average score is 36%

0%

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

Scroll to Top