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

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.