0% found this document useful (0 votes)
248 views2 pages

BPJ Lesson 13 Exercise

The document contains questions about ASCII codes, character conversions, and character properties. It asks about the ASCII codes for uppercase and lowercase letters, converting between cases, checking character types like letters and digits, and using Character class methods. Code snippets are provided to convert strings to uppercase, check for whitespace, and determine character properties.

Uploaded by

api-307096342
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
248 views2 pages

BPJ Lesson 13 Exercise

The document contains questions about ASCII codes, character conversions, and character properties. It asks about the ASCII codes for uppercase and lowercase letters, converting between cases, checking character types like letters and digits, and using Character class methods. Code snippets are provided to convert strings to uppercase, check for whitespace, and determine character properties.

Uploaded by

api-307096342
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

13-4

1. What is the ASCII code for A?


2. What is the ASCII code for Z?
3. What is the ASCII code for a?
4. What is the ASCII code for z?
5. How many letters are in the English alphabet?
6. What is the ASCII code for the character 0 (this is the number 0 and not the letter O)?
7. What is the ASCII code for the character 9?
8. What does the following code do?
char c;
for (int j = 97; j <= 122; j++) {
c = (char)(j 32);
System.out.print(c);
}
9. What does the following code do?
String s = Alfred E. Neuman;
char ch;
for (int x = 0; x < s.length( ); x++) {
ch = s.charAt(x);
if ( (ch <= 90) && (ch>=65) )
ch = (char)(ch + 32);
System.out.print(ch);
}
10. Write code that will convert
11. Write code that will convert
12. Is this legal?
char ch = V;
String sd = ch;

into a

into a character. ( consists of just one letter.)

13-5
13. Is this legal?
char ch = V;
char x = (char)(ch + 56);
14. Is this legal?
char aa = X;
15. char k = B;
System.out.println(k + 3); //Whats printed?
16. char k = B;
System.out.println( (char)(k + 3) ); //Whats printed?
17. Write code that will insure that an uppercase version of
18. Write code that will insure that a lowercase version of

is stored in
is stored in

.
.

19. If you have a character called

, what could you do to determine if its a digit?

20. If you have a character called

, what could you do to determine if its a letter?

21. If you have a character called


character?

, what could you do to determine if its an uppercase

22. If you have a character called


digit?

, what could you do to determine if its either a letter or a

23. If you have a character called


character?

, what could you do to determine if its a lowercase

24. Describe what the following code does.


for(int j = 0; j <= 127; j++)
{
char ch = (char)j;
if (Character.isWhitespace(ch) )
System.out.println(j);
}

You might also like