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







Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.