Java Quiz

0 votes, 0 avg
441

Java Questions

1 / 15

1. What is true about final class?

2 / 15

2. What does Object Oriented Programming means?

3 / 15

3. What is the function of javap command?

4 / 15

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

            }

       }

5 / 15

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

            }

        }

6 / 15

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

7 / 15

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

        class test 

        {

            int a;

            int b;

            void meth(int i , int j) 

            {

                i *= 2;

                j /= 2;

            }          

        }    

        class Output 

        {

            public static void main(String args[])

            {

                test obj = new test();

    	    int a = 10;

                int b = 20;             

                obj.meth(a , b);

                System.out.println(a + " " + b);        

            } 

        }

8 / 15

8. What is Truncation in Java?

9 / 15

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

            }

       }

10 / 15

10. Find the output of the following code.

        class leftshift_operator 

        {

            public static void main(String args[]) 

            {        

                 byte x = 64;

                 int i;

                 byte y; 

                 i = x << 2;

                 y = (byte) (x << 2);

                 System.out.print(i + " " + y);

            } 

        }

11 / 15

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

12 / 15

12. From the following statements which is a disadvantage of an java array?

13 / 15

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

14 / 15

14. Which exception is thrown when java is out of memory?

15 / 15

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

Your score is

The average score is 36%

0%

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

Scroll to Top