CJ_Slip_1A

Slip No. 1

A) Write a ‘java’ program to display characters from ‘A’ to ‘Z’.

1. Open Notepad.

2. Type the following code:

    public class DisplayCharacters {
    public static void main(String[] args) {
    for (char c = 'A'; c <= 'Z'; c++) {
    System.out.print(c + " ");
    }
    }
    }

3. Save the file with the name DisplayCharacters.java. Make sure to select "All Files" in the "Save as type" dropdown and add the .java extension manually.

4. Open the Command Prompt.

5. Compile the Java program by typing:
javac DisplayCharacters.java

6. Run the compiled Java program by typing:
java DisplayCharacters

7. output:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

No comments:

Post a Comment