Declaring and printing different variable types

Report a typo

Consider a program that declares three variables - one to store an integer, one to hold a boolean value, and another to store a character. The program must print these variables onto the console. Fill the blanks in the code to declare variables of appropriate types and initialize them with values of '10', 'true', and 'J' respectively.

Fill in the gaps with the relevant elements
public class Main {
    public static void main(String[] args) {
         number = 10;
         pi = 3.14;
         isJavaFun = true;
         firstLetter = 'J';
        System.out.println("Number: "+ number);
        System.out.println("Value of pi: "+ pi);
        System.out.println("Is Java fun?: "+ isJavaFun);
        System.out.println("First letter: "+ firstLetter);
    }
}

Create a free account to access the full topic