Java Characters Aptitude Questions and Answers.

This section contains Aptitude Questions and Answers on Java Character Class, char data type - reading, printing, converting and manipulating characters.

List of Java Characters Aptitude Questions

1) Correct syntax to create a character object.
  1. char ch=new char('A');
  2. Char ch=new Char('A');
  3. Character ch=new Character('A');
  4. Character ch=Character('A');

2) Correct method to check whether an entered character is space (whitespace) or not.
  1. boolean Character.isSpace(char val);
  2. boolean Character.isWhitespace(char val);
  3. boolean isWhitespace(char val);
  4. boolean isSpace(char val);

3) How to convert a character variable 'ch' into string?
  1. toString(ch);
  2. ch.toString();
  3. String.toString(ch);
  4. Character.toString(ch);

4) What will be printed by following code snippet?
char ch='a';
System.out.println(Character.toUppercase("value is: "+ch));
  1. Error
  2. value is: a
  3. value is: A
  4. value is:

5) What will be the output by following code snippet?
char x=-1;
System.out.println("value is: " +x);
  1. Error
  2. value is: -1
  3. value is: 255
  4. value is: 65535

Comments and Discussions!

Load comments ↻

Copyright © 2024 All rights reserved.