Java Questions & Answers – Integer and Floating Data Types

6
Created on By admin

Java Questions & Answers – Integer and Floating Data Types

1 / 10

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

 

 

2 / 10

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

 

3 / 10

3. 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)100L;

4 / 10

4. An expression involving byte, int, and literal numbers is promoted to which of these?

 

5 / 10

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

 

6 / 10

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

 

7 / 10

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

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

     

 

8 / 10

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

  1. class output {
  2.         public static void main(String args[])
  3.         {
  4.             double a, b,c;
  5.             a = 3.0/0;
  6.             b = 0/4.0;
  7.             c=0/0.0;
  8. 	    System.out.println(a);
  9.             System.out.println(b);
  10.             System.out.println(c);
  11.         }
  12.     }

9 / 10

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

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

10 / 10

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

  1.     class area {
  2.         public static void main(String args[])
  3.         {
  4.              double r, pi, a;
  5.              r = 9.8;
  6.              pi = 3.14;
  7.              a = pi * r * r;
  8.              System.out.println(a);
  9.         }
  10.     }

Your score is

The average score is 12%

0%

Leave a Reply

Your email address will not be published. Required fields are marked *