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
Mechanics of Materials (10th Edition)
Electric Circuits. (11th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Degarmo's Materials And Processes In Manufacturing
Starting Out with Java: From Control Structures through Objects (7th 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_forwardString and StringBuffer both represent String objects. Can we compare String and StringBuffer in Java?arrow_forwardTake a string from user and find it's unique identifier of that string in javaarrow_forward
- str is a String object.Write Java statements that finds the number of the alphanumeric characters (letter or digit) in str.Write only the Java statements that performs the above task, nothing else. with javaarrow_forwardin java plarrow_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_forward
- DescriptionA 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_forwardJava Programming Question 12 I am not sure how to do this question. Any simple input and output would be appreciated.arrow_forwardJAVAarrow_forward
- Strings animal1 and animal2 are read from input. Each string consists of at least two animals, separated by "+" and surrounded by "(" and ")". Assign firstltems with the first animal from each string, separated by "+". Ex: If the input is: (cougar+llama+moose) (sheep+snake+gecko) then the output is: cougar+sheep 1 import java.util.Scanner; N3 ti 2 3 public class JoinMultipleFirsts { 4 5 6 7 8 9 10 11 12 13 14 15 16 17 public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String animall; String animal2; String firstOfAnimal1; String firstOfAnimal2; String firstItems; animal1 = scnr.nextLine(); animal2 = scnr.nextLine(); /* Your code goes here */ System.out.println(firstItems);arrow_forwardJava Programming Question 12 error: I have this else error in my code and not sure how to fix it. Help would be appreciated!arrow_forwardJava pleasearrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT