How can we check if a particular character is upper case in Java ?
Javasearch.buggybread.com

Search Interview Questions


 3361 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Java - Interview Questions and Answers

 Q1. How can we check if a particular character is upper case in Java ?Core Java2017-07-29 09:58:48

Ans. 1. We can compare the ascii value of the character. Ascii for Capital case character is from 65 to 90.

2. We can compare to see if lowerCase of the character is not equal to character itself.

For example -

if character is 'a' the following code

new StringBuilder(char).toString().toLowerCase().equals(new StringBuilder(char)

will return true and hence char is lower case

if character is 'A' the following code

new StringBuilder(char).toString().toLowerCase().equals(new StringBuilder(char)

will return false and hence char is upper case

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     check upper case character  character


Related Questions

  Why Char array is preferred over String for storing password?
  What is a stream and what are the types of Streams and classes of the Streams?
 What are the factors on which customers are charged for using S3 ?
  Which class is used to read streams of characters from a file?
  Write an SQL to find all records having all upper case alphanumeric characters in a field ?
  Write an SQL to find all records having all numeric characters in a field ?
 What will be the output of following code ?

System.out.println((int)'a');
 What will be the output of

System.out.println((Integer)'a');
 What is the character limit of url and doesn it apply to GET and POST Requests ?
 Write a Program that prints words longer than 5 characters in a String

For example

We are what we repeatedly do; excellence, then, is not an act but a habit

should print

repeatedly
excellence



Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: