Suppose s1, s2, and s3 are three strings, given as follows:
String s1 = "Welcome to Java";
String s2 = "
String s3 = "Welcome to Java";
What are the results of the following expressions?
(a) s 1 == s2
(b) s2 == s3
(c) s1 .equals(s2)
(d) s2.equals(s3)
(e) s1 .compareTo(s2)
(f) s2.compareTo(s3)
(g) s2. compareTo(s2)
(h) s1. charAt (0)
(i) s1. indexOf (' j ')
(j) s1.indexOf("to")
(k) s1. last IndexOf ('a')
(1) s1 .1 astlndexOf ("o" , 15)
(m) s1.1ength()
(n) s1 .substring(5)
(o) s1 .substring(5, 11)
(p) s1.startsWith("Wel")
(q) s1.endsWith("Java")
(r) s1 .toLowerCase()
(s) s1 .toUpperCase()
(t) s1 .concat (s2)
(u) s1.contain(s2)
(v) "\t Wel \t".trim()
Trending nowThis is a popular solution!
Chapter 4 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Using MIS (10th Edition)
Programming in C
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Starting Out with Python (4th Edition)
Artificial Intelligence: A Modern Approach
- Given a first string on one line and a second string on a second line, append the second string to the first string and then output the result. Ex: If the input is: Fuzzy bear !!! the output is: Fuzzy bear!!! Note: Using a pre-defined string function, the solution can be just one line of code. 1 #include 2 #include 3 using namespace std; 4 5 int main() { string strInput; string endStr; 6. 7. 8. getline(cin, strInput); getline(cin, endStr); 10 11 12 cout << strInput << endl; return 0; 13 14 15 }arrow_forwardSolve only 3rd partarrow_forwardjava: Run length coding is a method to represent a string in a more compact manner. Each character that occurs more than 2 times in a row is represented by the character and a number following it. Two examples are: "abba" → "abba""abcccbbbba" → "abc3b4a"Write a function that calculates how many characters the encoded string is shorter than the original.arrow_forward
- Use C++arrow_forwardpublic static String pancakeScramble(String text) This nifty little problem is taken from the excellent Wolfram Challenges problem site where you can also see examples of what the result should be for various arguments. Given a text string, construct a new string by reversing its first two characters, then reversing the first three characters of that, and so on, until the last round where you reverse your entire current stringarrow_forwardImplement the following function which accepts a string as parameter and reverses it, without using any function from the string library. void strReverse(char *str)arrow_forward
- We know that a sandwich can make from 2 breads, your task is to take a string from user which contains atmost 2 "breads" & to print which is in between both breads. Programming Language: Java & you havearrow_forwardIn Python, The function add_char_counts takes three parameters: a string s and two strings of length 1, char1 and char2, and returns the total number of times either char1 or char2 appears in s. For example, the word "scallions" has 2 s's and 1 n, so add_char_counts("scallions", "s", "n") returns 3. Hint: Use a string method to help solve this problem (count). You do not need an accumulator. For example: Test Result print(add_char_counts('Indiana', 'a', 'b')) 2 print(add_char_counts('BAHAMAS', 'A', 'B')) 4 print(add_char_counts('Mississippi', 'i', 'M')) 5 print(add_char_counts("spam spam spam spam", "s", "p")) 8arrow_forwardQ1__;. A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. Given a string s, return true if it is a palindrome, or false otherwise. Example 1: Input: s = "A man, a plan, a canal: Panama" Output: true Explanation: "amanaplanacanalpanama" is a palindrome. Example 2: Input: s = "race a car" Output: false Explanation: "raceacar" is not a palindrome..arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education