Search Interview Questions | ![]() ![]() Click here and help us by providing the answer. ![]() Click Correct / Improve and please let us know. |
|
| ||||
Core Java - Interview Questions and Answers for 'Character' - 10 question(s) found - Order By Newest | ||||
| ||||
Ans. A Stream is an abstraction that either produces or consumes information. There are two types of Streams : Byte Streams: Provide a convenient means for handling input and output of bytes. Character Streams: Provide a convenient means for handling input & output of characters. Byte Streams classes: Are defined by using two abstract classes, namely InputStream and OutputStream. Character Streams classes: Are defined by using two abstract classes, namely Reader and Writer. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 bits, it is usually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
![]() | ||||
| ||||
Ans. The ascii value of a i.e 97 | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. It will result in compilation error as primitive char cannot be casted to Integer object, alternatively we can cast it to primitive int like following System.out.println((int)'a'); | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. 65 to 90 for capital case alphabets 97 to 122 for lower case alphabets | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. A way of encoding characters as binary numbers. The Unicode character set includes characters used in many languages, not just English. Unicode is the character set that is used internally by Java. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. 16 bits | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. public class BuggyBread { public static void main(String args[]) { Map<Character, Integer> countMap = new HashMap(); String str = "hello world"; for (char character : str.toCharArray()) { if (countMap.containsKey(character)) { countMap.put(character, countMap.get(character) + 1); } else { countMap.put(character, 1); } } System.out.println(countMap); } } | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
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 | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. String has an argument constructor that take char array as argument and creates a string. There is no constructor available with String that takes in a character and creates a String. We can use StringBuilder which has a char argument constructor. | ||||
![]() | ||||
![]() ![]() ![]() | ||||