Tuesday, July 13, 2021

2. Write a Java program to print an int, a double and a char on screen.

public class Main {
      public static void main(String[] args) {
          System.out.println("Int");
          System.out.println("Double");
          System.out.println("Char");
     }
}

NOTE:
  • Every input is given in the question so we do not need to use Scanner class.
  • Used System.out.println(""); to print on the screen .
  • In java semi-colon (;) is very important.
  • Semi-colon makes the compiler know where a line of code is ending.

No comments:

Post a Comment