Suppose s1, s2, s3, and s4 are four strings, given as follows:
String s1 = “Welcome to Java”;
String s2 = s1;
String s3 = new String(“We1come to Java”);
String s4 = “Welcome to Java”;
What are the results of the following expressions?
a. s1 == s2
b. s1 == s3
c. s1 == s4
d. s1.equals(s3)
e. s1.equals(s4)
f. “Welcome to Java”.replace(“Java”, “HTML”)
g. s1.replace(‘o’, ‘T’)
h. s1.replaceAll(“o”, “T”)
i. s1.rep1aceFirst(“o”, “T”)
j. s1.toCharArray()
Trending nowThis is a popular solution!
Chapter 10 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Java: An Introduction to Problem Solving and Programming (7th Edition)
Using MIS (10th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Starting Out with C++: Early Objects
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
- Q1__;. 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_forwardThis is the issue and must be written in java:Write an application that accepts three specific User strings and shows either You have not entered the words alphabetically or You have entered the strings alphabetically depending on whether the strings were in alphabetic order.arrow_forwardJava Programmming Suppose that s1 and s2 are given as follows: StringBuilder s1 = new StringBuilder("Java"); StringBuilder s2 = new StringBuilder("HTML"); Show the value of s1 after each of the following statements. Assume that the statements are independent. a. s1.append(" is fun"); b. s1.append(s2); c. s1.insert(2, "is fun"); d. s1.insert(1, s2); e. s1.charAt(2); f. s1.length(); g. s1.deleteCharAt(3); h. s1.delete(1, 3); i. s1.reverse(); j. s1.replace(1, 3, "Computer"); k. s1.substring(1, 3); l. s1.substring(2);arrow_forward
- Java Programmming Suppose that s1 and s2 are given as follows: StringBuilder s1 = new StringBuilder("Java"); StringBuilder s2 = new StringBuilder("HTML"); Show the value of s1 after each of the following statements. Assume that the statements are independent. a. s1.append(" is fun"); b. s1.append(s2); c. s1.insert(2, "is fun"); d. s1.insert(1, s2); e. s1.charAt(2); f. s1.length(); g. s1.deleteCharAt(3); h. s1.delete(1, 3); i. s1.reverse(); j. s1.replace(1, 3, "Computer"); k. s1.substring(1, 3); l. s1.substring(2); Expected Output: (a) Java is fun(b) JavaHTML(c) Jais funva(d) JHTMLava(e) v(f) 4(g) Jav(h) Ja(i) avaJ(j) JComputera(k) av(l) vaarrow_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_forwardString and StringBuffer both represent String objects. Can we compare String and StringBuffer in Java?arrow_forward
- In java please help with the following: Given a string that contains space separated words, write an application that displays the words in ascending order (If two words are the same, display only one). You need to use the right data structure for storing the words. For example, for input:String input="apple banana apple orange blueberry"; The program will print out: apple banana blueberry orangearrow_forwardJava Program - Functions With Parameters and No Return Values Create a function named palindrome that asks the user a string input if called. If the string is a palindrome, print “{input} is a palindrome!”, otherwise print “{input} is not a palindrome!”. In the main function, call the palindrome function. Input 1. One line containing a single string Output Enter a string: racecar racecar is a palindrome!arrow_forwardTake two string from user and print 1 if the fırst string is greater than string 2 and 0 if both equal and -1 if the second is greater than 1. In javaarrow_forward
- Suppose that you declare two String objects as: String word1 = new String("Computer"); String word2 = new String("Science"); Write an if statement that checks to see if the two strings are equal.arrow_forwardQ1: Write a C# program that reads the information list of n students (name, age, List of 10 degrees and average) in a single string for each student in the following form "[Name: D₁, D2,.....D10];>"; and compute the average from the degrees list. Then, print the information (all fields) of any student has the following properties: Name doesn't start with "Ba" and ends with "ky" The Age less than 45 and greater than 30 Successful in 7 degrees and the Average doesn't exceed 70 Note: Both Structure and LINQ Principles must be used in the above programarrow_forwardDescriptionA researcher is analyzing DNA. A DNA can be represented as a string composed of the characters A, G, C, or T.One day, researchers found a strange DNA, which is Smooth Repeated DNA. The DNA is represented by a string that has infinite length. The string has a repeating pattern, i.e. the DNA string 0 is repeated an infinite number of times. For example, if0 = "????", then = "???????????? . . . ".According to researchers, a DNA is said to be special if it contains substrings . Determine whetheris a substring of . Squad FormatA line containing the two strings 0 and . Output FormatA line that determines whether it is a substring of . Issue “YES” ifis a substring of . Output “NO” otherwise. Example Input and Output Input Example Example Output AGCT GC YES AGCT TA YES AGCT GT No AGCT TAGCTAGCT YES AGGACCTA CTAA YES Explanation ExampleIn the first to fourth test case examples, is worth "???????????? . . . ". The part in bold is one of the…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