My Report

Java Basic Online Test – 1


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. An expression involving byte, int, and literal numbers is promoted to which of these?

2. Which of the following are legal lines of Java code?

   1. int w = (int)888.8;
   2. byte x = (byte)100L;
   3. long y = (byte)100;
   4. byte z = (byte)1000L;

3. Which data type value is returned by all transcendental math functions?

4. What is the range of byte data type in Java?

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

    class average {
        public static void main(String args[])
        {
            double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5};
            double result;
            result = 0;
            for (int i = 0; i < 6; ++i) 
                result = result + num[i];
	    System.out.print(result/6);
                	
        } 
    }

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

    class area {
        public static void main(String args[]) 
        {    
             double r, pi, a;
             r = 9.8;
             pi = 3.14;
             a = pi * r * r;
             System.out.println(a);
        } 
    }

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

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

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

class output {
        public static void main(String args[]) 
        {
            double a, b,c;
            a = 3.0/0;
            b = 0/4.0;
            c=0/0.0;
	   
	    System.out.println(a);
            System.out.println(b);
            System.out.println(c);
        } 
    }

9. Which of these literals can be contained in float data type variable?

10. What is the range of short data type in Java?


 

Start practicing “1000 MCQs on Java”, and once you are ready, you can take tests on all topics by attempting our “Java Test Series”.

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.