Declare Variables

Lab Java Beginner 10 points

Declare an int age = 21, a double height = 1.75, a char grade = 'A', a boolean student = true and a String name = "Ravi". Print each on its own line.

Input

None.

Output

Five lines.

Example

Output

21
1.75
A
true
Ravi
Sample output available
Editor
Java

Hints

Java is statically typed: write the type before the variable name.

char uses single quotes, String uses double quotes.

Solution explanation

Primitive types (int, double, char, boolean) store values directly; String is a class.

Show solution
public class Main {
    public static void main(String[] args) {
        int age = 21;
        double height = 1.75;
        char grade = 'A';
        boolean student = true;
        String name = "Ravi";
        System.out.println(age);
        System.out.println(height);
        System.out.println(grade);
        System.out.println(student);
        System.out.println(name);
    }
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD