Computer Science, asked by Anonymous, 1 year ago

Write a program to declare and initialize all the primitive data types and display them.

Answers

Answered by Anonymous
7

class Demo {

public static void main(String args[]) {

 byte x;

 int a = 270;

 double b = 128.128;

 System.out.println("int converted to byte");

 x = (byte) a;

 System.out.println("a and x " + a + " " + x);

 System.out.println("double converted to int");

 a = (int) b;

 System.out.println("b and a " + b + " " + a);

 System.out.println("\ndouble converted to byte");

 x = (byte)b;

 System.out.println("b and x " + b + " " + x);

}

}

Answered by MarshmellowGirl
13

✿━━━━@Mg━━━━✿

\boxed{Explained\:Answer}

______________________________

✿━━━━@Mg━━━━✿

public class Addition {

   public static void main (String args[] ) {

      int firstNumber = 3;

      int secondNumber = 4;

      int result = firstNumber +

secondNumber ;

      System.out.println ( "The result of

adding "+ firstNumber + " and "+ secondNumber + " is "+ result );   }

}

Similar questions