java exam

0 votes, 0 avg
387

Java Questions

1 / 15

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

2 / 15

2. What is Truncation in Java?

3 / 15

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

4 / 15

4. The concept of multiple inheritances is implemented in Java by

I. Extending two or more classes.
II. Extending one class and implementing one or more interfaces.
III. Implementing two or more interfaces.

5 / 15

5. Identify the output of the following program.

String str = “Hellow”;
System.out.println(str.indexOf(‘t));

6 / 15

6. In Iterator, hasMoreElements() method of Enumeration has been changed to:

7 / 15

7. Which of these method of class String is used to remove leading and trailing whitespaces?

8 / 15

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

9 / 15

9. Find the output of the following program.

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

10 / 15

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

            }

       }

11 / 15

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

12 / 15

12. Find the output of the following program.

public class MyFirst {  
 public static void main(String[] args) {  
 MyFirst obj = new MyFirst(n);  
     }  
     static int a = 10;  
     static int n;  
     int b = 5;  
     int c;  
     public MyFirst(int m) {  
           System.out.println(a + ", " + b + ", " + c + ", " + n + ", " + m);  
       }  
    // Instance Block  
      {  
         b = 30;  
         n = 20;  
      }   
    // Static Block  
      static   
    {  
              a = 60;  
         }   
     }  

13 / 15

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

            }

        }

14 / 15

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

15 / 15

15. Which two classes use the Shape class correctly?

A. public class Circle implements Shape 
   {
    private int radius;
   }
B. public abstract class Circle extends Shape 
   {
    private int radius;
   }
C. public class Circle extends Shape 
   {
   private int radius;
   public void draw();
   }
D. public abstract class Circle implements Shape 
   {
    private int radius;
    public void draw();
   }
E. public class Circle extends Shape 
   {
    private int radius;
    public void draw()
    {
     /* code here */
    }
   }
F. public abstract class Circle implements Shape 
   {
     private int radius;
     public void draw() 
     { 
      /* code here */ 
     }
   }

Your score is

The average score is 35%

0%

Scroll to Top