Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5971191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:28:57+00:00 2026-05-22T20:28:57+00:00

When running the following program and inputing a letter, one of the output windows

  • 0

When running the following program and inputing a letter, one of the output windows says that the letter is a digit when it is clearly not. Why?

import javax.swing.JOptionPane;

/**
 * This program demonstrates some of the Character
 * class's character testing methods
 * 
 *
 */
public class CharacterTest {

public static void main(String[] args){
    String input;   //To hold the user's input
    char ch;    //To hold a single character

    //Get a character from the user and store
    //it in the ch variable
    input=JOptionPane.showInputDialog("Enter "+
            "any single character.");

    ch= input.charAt(0);

    //Test the character
    if(Character.isLetter(ch)){
        JOptionPane.showMessageDialog(null, "This is a letter.");
    }

    if(Character.isDigit(ch));{
        JOptionPane.showMessageDialog(null, "Thit is a digit.");
    }

    if(Character.isLowerCase(ch)){
        JOptionPane.showMessageDialog(null, "That is a lowercase"+
                " letter");
    }

    if(Character.isUpperCase(ch)){
        JOptionPane.showMessageDialog(null, "That is an uppercase"+
                " letter");
    }

    if(Character.isSpaceChar(ch)){
        JOptionPane.showMessageDialog(null, "That is an uppercase"+
                " letter");
    }

    if(Character.isWhitespace(ch)){
        JOptionPane.showMessageDialog(null, "That is an uppercase"+
                " letter");
    }

    System.exit(0);

}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:28:58+00:00Added an answer on May 22, 2026 at 8:28 pm
    if(Character.isDigit(ch));{
            JOptionPane.showMessageDialog(null, "Thit is a digit.");
        }
    

    That means:

    JOptionPane.showMessageDialog(null, "Thit is a digit.");
    

    without any condition, so it will always print that it’s a digit.

    By the way, neither spaces nor white spaces (funny how Java distinguishes between the two) are “uppercase letters”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When running a Python program that reads from stdin, I get the following error:
Hi I am running following command from my post build event: C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\mt.exe
I have a Python program running a thread that consistently outputs the following: (my_program.py:12313):
Quiz question: What is the output of running the following program: Sub Main() Try
I am running the following java program in the Eclipse IDE: import java.net.*; import
I am getting he following Exception while running my Quartz Schdular program. Below is
I am running following query in SQL*Plus CREATE TABLE tbl_audit_trail ( id NUMBER(11) NOT
When running the following code it leaves out one row. When I do a
The following program compiles with g++ but then crashes upon running: class someClass {
The following program terminates correctly: import System.Random randomList = mapM (\_->getStdRandom (randomR (0, 50000::Int)))

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.