Code:
import static java.lang.Character.*; //Importing ALL the methods from Character class
import static java.lang.Math.random; //Importing the method random() from Math class
public class AlphaMethods {
public static void main(String[] args)
{
char alpha=(char)(128*random()); //Used to generate a random number and cast it into char
System.out.println("The Generated char is: " + alpha); //To print the generated character and for manual verification
if(isLetter(alpha)) {
if(isUpperCase(alpha)) {
System.out.println("Upper Case Alphabet");
}
else {
System.out.println("Lower Case Alphabet");
}
}
else {
if(isDigit(alpha)) {
System.out.println("Digit");
}
else {
if(isWhitespace(alpha)) {
System.out.println("White Space");
}
else {
System.out.println("Symbol");
}
}
}
}
}