My Report

Java Programming Practice Test 4


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

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

 
    class Output 
    {
        public static void main(String args[]) 
        {
            Long i = new Long(256);  
            System.out.print(i.hashCode());
        }
    }

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

   
    class isinfinite_output 
    {
        public static void main(String args[]) 
        {
            Double d = new Double(1 / 0.);  
            boolean x = d.isInfinite();
            System.out.print(x);
        }
    }

3. Which of these class is a superclass of all other classes?

4. Which of these method returns a largest whole number less than or equal to variable X?

5. Which of these class is used to read and write bytes in a file?

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

   
    class Output
    {
        public static void main(String args[])
        {
            Double i = new Double(257.5);  
            Double x = i.MIN_VALUE;
            System.out.print(x);
        }
    }

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

 
    class exception_handling 
    {
        public static void main(String args[]) 
        {
            try 
            {
                int a[] = {1, 2,3 , 4, 5};
                for (int i = 0; i < 7; ++i) 
                    System.out.print(a[i]);
            }
            catch(ArrayIndexOutOfBoundsException e) 
            {
        	System.out.print("0");        	
            }
        }
    }

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

   
    class Output
    {
        public static void main(String args[])
        {
	    Double i = new Double(257.578123456789);  
            float x = i.floatValue();
            System.out.print(x);
        }
    }

9. Which of the following methods Byte wrapper return the value as a double?

10. Which of these method is a rounding function of Math class?


 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.