Computer

Data Types And Variables MCQs

Practice Data Types And Variables MCQs for competitive exams.

Data Types And Variables MCQs

Practice questions from this topic.

What will be the output of the following Java code snippet? enum Enums { A, B, C; private Enums() { System.out.println(10); } } public class MainClass { public static void main(String[] args) { Enum en = Enums.B; } }

  1. A. 10 10 10
  2. B. Compilation Error
  3. C. 10 10
  4. D. Runtime Exception
Report Error

What is the limitation of toString() method of BigDecimal?

  1. A. There is no limitation
  2. B. toString returns null
  3. C. toString returns the number in expanded form
  4. D. toString uses scientific notation
Report Error

What will be the output of the following Java program? class mainclass { public static void main(String args[]) { boolean var1 = true; boolean var2 = false; if (var1) System.out.println(var1); else System.out.println(var2); } }

  1. A. 0
  2. B. 1
  3. C. true
  4. D. false
Report Error

What will be the output of the following Java code snippet? class A { } enum Enums extends A { ABC, BCD, CDE, DEF; }

  1. A. Runtime Error
  2. B. Compilation Error
  3. C. It runs successfully
  4. D. EnumNotDefined Exception
Report Error

Which class is a library of functions to perform arithmetic operations of BigInteger and BigDecimal?

  1. A. MathContext
  2. B. MathLib
  3. C. BigLib
  4. D. BigContext
Report Error

How to get UTC time?

  1. A. Time.getUTC()
  2. B. Date.getUTC()
  3. C. Instant.now()
  4. D. TimeZone.getUTC()
Report Error

What is the order of variables in Enum?

  1. A. Ascending order
  2. B. Descending order
  3. C. Random order
  4. D. Depends on the order() method
Report Error

Which of these is long data type literal?

  1. A. 0x99fffL
  2. B. ABCDEFG
  3. C. 0x99fffa
  4. D. 99671246
Report Error

Literals in java must be appended by which of these?

  1. A. L
  2. B. l
  3. C. D
  4. D. L and I
Report Error

What will be the output of the following Java 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] + "" ); i++; } } }

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

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); } }

  1. A. 16.34
  2. B. 16.566666644
  3. C. 16.46666666666667
  4. D. 16.46666666666666
Report Error

What will be the output of the following Java code? class asciicodes { public static void main(String args[]) { char var1 = 'A'; char var2 = 'a'; System.out.println((int)var1 + " " + (int)var2); } }

  1. A. 162
  2. B. 65 97
  3. C. 67 95
  4. D. 66 98
Report Error