• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
Switch to Dark Mode

Java Data Types

Last Updated : Mar 22, 2024
Discuss
Comments

Question 1

C
class Main {   
   public static void main(String args[]) {      
         int t;      
         System.out.println(t); 
    }   
}
  • A

    0

  • B

    garbage value

  • C

    compiler error

  • D

    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; 
      } 
    } 
} 
  • A

    Hello

  • B

    Empty Output

  • C

    Compiler error

  • D

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

    }
}
  • A

    8

  • B

    8.8

  • C

    8.800000095367432

Question 4

Which of the following is a valid Java data type for storing a true/false value?

  • A

    int

  • B

    float

  • C

    boolean

  • D

    String

Master JAVA and also get 90% fee refund on completing 90% course in 90 days! Take the Three 90 Challenge today.

After successfully processing refunds worth over INR 5 Cr, GeeksforGeeks is back with the Three 90 challenge and this is your chance to upskill and get 90% refund. What more motivation do you need? Start the challenge right away!

There are 4 questions to complete.

Take a part in the ongoing discussion