Java - Data Types MCQ Questions

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

A. -128 to 127
B. -32768 to 32767
C. -2147483648 to 2147483647
D. None of the mentioned

View Answer

22. 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;

A. 1 and 2
B. 2 and 3
C. 3 and 4
D. All statements are correct

View Answer

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

A. int
B. byte
C. long
D. float

View Answer

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

A. -1.7e+308
B. -3.4E+38
C. +1.7e+308
D. -3.4E+50

View Answer

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

A. int
B. float
C. double
D. long

View Answer

26. Which of these coding types is used for data type characters in Java?

D. None of the mentioned

View Answer

27. Which one is a valid declaration of a boolean?

A. boolean b1 = 1;
B. boolean b2 = ‘false’;
C. boolean b3 = false;
D. boolean b4 = ‘true’

View Answer

28. What is the output of this program?

class array_output {
   public static void main(String args[])
       char array_variable [] = new char[10];
       for (int i = 0; i < 10; ++i) {
            array_variable[i] = 'i';
            System.out.print(array_variable[i] + """" );

A. i i i i i
B. 0 1 2 3 4
C. i j k l m
D. None of the mentioned

View Answer

29. Which of these is long data type literal?

A. 0x99fffL
C. 0x99fffa
D. 99671246

View Answer

30. Which of these can be returned by the operator &?

A. Integer
B. Boolean
C. Character
D. Integer or Boolean

View Answer

Also check :


* You must be logged in to add comment.