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)
- An expression using the `+' operator in Java produces : (a String expressing the sum of the operands, if they are numbers of different types? the sum of the left and right operands, provided they are numbers of the same type? a concatenation of the left and right operands, provided they are both Strings? a String representation joining the left and right operand, if they are numbers of different types? a String concatenation if one of the operands is non-numeric? ) . The operator also offers a convenient way to turn any value or object into its String representation. This involves specifying :( the object as the right operand and null as the left operand? the object as the right operand only? the object as the left operand only? the object as right operand and the empty string as the left operand? the object as one operand and the empty string as the other?) Select right answersarrow_forward3. Write a Java program that takes the user to provide a single character from the alphabet. Print Vowel or Consonant, depending on the user input. If the user input is not a letter (between a and z or A and Z), or is a string of length > 1, print an error message.4. Write a program in Java to input 5 numbers from keyboard and find their sum and average.arrow_forwardIn Java, Write a program that prompts the user to enter a full name consisting of three names (first middle last) into one String variable. Then use methods of class String to: print the number of characters in the full name, including spaces print just the middle name and the number of characters in it. print the three initials of the name print the last name in all upper case. print the full name in the usual alphabetical format (last, first middle) and proper case.arrow_forward
- Given the following Java code: String str1 = “Java is useful!”; String str2= “Java is cool”; write the result of to each of the following questions: write a Java expression that compares if str1 is equal to str2 write a Java expression that displays string str1arrow_forwardWrite a Java regular expression for each of the following: a. Phone numbers, such as (609) 555-1234 b. Social Security numbers, such as 123-45-6789 c. Dates, such as December 31, 1999arrow_forward(Java) What will the following display to the console? Work out the solution by hand (don't run the code, until after you have worked it out by hand). StringBuilder sb1 = new StringBuilder("Cat");StringBuilder sb2 = new StringBuilder(sb1.replace(2, 3, "Rat").append("Mat"));sb2.append("Sat!");System.out.println(sb1);System.out.println(sb2);arrow_forward
- I'm having trouble getting my problem to display correctly in java. I want the final message to show up in one dialog window Joptionpane but its give me each and every word seperately. How would I fix this to the phrase and then each word that was initally entered? for (String pigLatin : arr) {output = String.format(pigLatin.substring(1) + pigLatin.substring(0, 1) + "ay ");JOptionPane.showMessageDialog(null, "The phrase you entered translates to:\n" + output);arrow_forwardPLEASE HELP ME FIND THE JAVA CODE FOR THIS PROBLEM 4. Is It You, Cody? by CodeChum Admin Can you identify if Cody's name is spelled right? If so, then make a program that accepts four one-letter strings separated by space and print "Correct" if the inputted strings, combined in order, spell the name Cody correctly. If not, print "Wrong". It doesn't matter if it's in uppercase or lowercase, as long as it's spelled correctly, it's considered correct. Now, will you take on this task? Input A line containing four one-letter strings separated by a space. c·O·D·y Output A line containing a string. Correctarrow_forwardI need help with this Java problem as it's explained in the image below: Palindrome (Deque) A palindrome is a string that reads the same backwards and forwards. Use a deque to implement a program that tests whether a line of text is a palindrome. The program reads a line, then outputs whether the input is a palindrome or not. Ex: If the input is: senile felines! the output is: Yes, "senile felines!" is a palindrome. Ex: If the input is: rotostor the output is: No, "rotostor" is not a palindrome. Ignore punctuation and spacing. Assume all alphabetic characters will be lowercase. Special case: A one-character string is a palindrome. Hint: The deque must be a Deque of Characters, but ordinary chars will be automatically converted to Characters when added to the deque. Java Code: import java.util.Scanner; import java.util.LinkedList; import java.util.Deque; public class LabProgram { public static void main(String[] args) { Scanner scnr = new Scanner(System.in);…arrow_forward
- Code please.How to print all permutations of a String in Java?.arrow_forwardWrite a Program that take 2 string from user and print the whole with greetings. Those 2 strings are first name and last name in javaarrow_forwardWrite a java program Take two test Strings (StrFirstName and StrLastName) as input from User and Demonstrate the use of at least ten String Class Methods. (Use your own first and last name). (Source code + Output). First Name: Syeda Last Name: Humnaarrow_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