• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Java Data Types

Question 1

C
class Main {   
   public static void main(String args[]) {      
         int t;      
         System.out.println(t); 
    }   
}
  • 0
  • garbage value
  • compiler error
  • runtime error

Question 2

Predict the output of following Java program. C
class Test { 
    public static void main(String[] args) { 
      for(int i = 0; 0; i++) 
      { 
          System.out.println(\"Hello\"); 
          break; 
      } 
    } 
} 
  • Hello
  • Empty Output
  • Compiler error
  • Runtime error

Question 3

Predict the output of the following program. Java
 class Test
{
    public static void main(String[] args)
    {
        Double object = new Double(\"2.4\");
        int a = object.intValue();
        byte b = object.byteValue();
        float d = object.floatValue();
        double c = object.doubleValue();

        System.out.println(a + b + c + d );

    }
}
  • 8
  • 8.8
  • 8.800000095367432

Question 4

Which of the following statements is/are TRUE regarding JAVA ? (a) Constants that cannot be changed are declared using the ‘static’ keyword. (b) A class can only inherit one class but can implement multiple interfaces.
  • Only (a) is TRUE.
  • Only (b) is TRUE.
  • Both (a) and (b) are TRUE.
  • Neither (a) nor (b) are TRUE.

There are 4 questions to complete.

Last Updated :
Take a part in the ongoing discussion