Java Strings Aptitude Questions and Answers.

This section contains Aptitude Questions and Answers on Java Strings Class - Reading Strings, Printing Strings, Converting and Manipulating String. This section also covers methods of the String class.

List of Java Strings Aptitude Questions

1) Is following statement is correct?
System.out.println("My name is ".concat("Mike"));
  1. Yes
  2. No

2) What will be the output by following code snippet?
System.out.printf("%d,%f",10,20.35);
  1. Error
  2. 10,20.35
  3. 10,20.350000
  4. 10,20.00

3) What is the return type of String.compareTo() method.
  1. boolean
  2. byte
  3. char
  4. int

4) Which method is used to compare two strings ignoring the case?
  1. compareToIgnoreCase()
  2. compareToI()
  3. compareToWithoutCase()
  4. None of these

5) What will be the output by following code snippet?
String text1="I am Mike";
String text2="I am Nike";
System.out.println(text1.contentEquals(text2)); 
  1. true
  2. false
  3. -1
  4. 1











Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.



Comments and Discussions


We are using Google to publish ads on our website; Google has its own privacy policies. They may save log, cookies on your system. Google may also collect information of your system like IP address, region, city, country. For more details please go through the Google’s privacy policy.