Java Quiz 4 : Literals, Variables & Type Conversions

    Welcome to your Java Quiz 4 : Literals, Variables & Type Conversions

    1. Which of these is long data type literal?
    2. Which of these can be returned by the operator ?
    3. Literals in java must be appended by which of these?
    4. Literal can be of which of these data types?
    5. Which of these can not be used for a variable name in Java?
    6. What will be the output of the following Java program?
    1.  class evaluate 
    2.  {
    3.  public static void main(String args[]) 
    4.  {
    5.  int a[] = {1,2,3,4,5};
    6.  int d[] = a;
    7.  int sum = 0;
    8.  for (int j = 0; j < 3; ++j)
    9.  sum += (a[j] * d[j + 1]) + (a[j + 1] * d[j]);
    10.  System.out.println(sum);
    11.  } 
    12.  }
    7. What will be the output of the following Java program?
    1.  class array_output 
    2.  {
    3.  public static void main(String args[]) 
    4.  {
    5.  int array_variable [] = new int[10];
    6.  for (int i = 0; i < 10; ++i) {
    7.  array_variable[i] = i/2;
    8.  array_variable[i]++;
    9.  System.out.print(array_variable[i] + " ");
    10.  i++;
    11.  }
    12.  
    13.  } 
    14.  }
    8. What will be the output of the following Java program?
    1.  class variable_scope 
    2.  {
    3.  public static void main(String args[]) 
    4.  {
    5.  int x;
    6.  x = 5;
    7.  {
    8.  int y = 6;
    9.  System.out.print(x + " " + y);
    10.  }
    11.  System.out.println(x + " " + y);
    12.  } 
    13.  }
    9. Which of these is an incorrect string literal?
    10. What will be the output of the following Java program?
    1.  class dynamic_initialization 
    2.  {
    3.  public static void main(String args[]) 
    4.  {
    5.  double a, b;
    6.  a = 3.0;
    7.  b = 4.0;
    8.  double c = Math.sqrt(a * a + b * b);
    9.  System.out.println(c);
    10.  } 
    11.  }
    11. Which of these is necessary condition for automatic type conversion in Java?
    12. What is the prototype of the default constructor of this Java class?
     public class prototype { }
    13. What will be the error in the following Java code?
     byte b = 50; b = b * 50;
    14. If an expression contains double, int, float, long, then the whole expression will be promoted into which of these data types?
    15. What is Truncation is Java?