Question

JAVA PROGRAMMING

I want to make sure I have learned the compareto statements correct and other things. This was on my lecture slide today and I don't understand the compare to regarding how they get values for the strings. Please answer the following.Suppose that s1, s2, and s3 are three strings, given as follows String s1 = Welcome to Java. String s2 = Programming is fun. String s3- Welcome to Java hat are the results of the following expressions? (a) s1 = s2 (b) s2 =-33 (c) s1.equals(s2) (d) s1.equals(s3) (e) s1.compare To(s2) (f) s2.compareTo(s3) (g) s2.compareTo(s2) (h) s1.charAt(0) (i) s1.indexOf(j) (j) s1.indexOf(to) (k) s1.lastlndexOf(a) (I) s1.lastlndexOf(o, 15) (m) s1.length() (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.contains(s2) (v)\t Wel \t.trim)

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
JAVA PROGRAMMING I want to make sure I have learned the compareto statements correct and other...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Write Java Programs to perform the following: 1. To create a new String object 2. To...

    Write Java Programs to perform the following: 1. To create a new String object 2. To find the length of the string 3. Concatenation operator 4. To display the content in String array 5. A complete Java Program that incorporates the following String methods taught in class a. toUpperCase()) b. to LowerCase()) C. replace('0','A')) d. s1.length() e. compareTo(s1)) methods taught in class a. toUpperCase()) b. to LowerCase()) C. replace('0','A')) d. s1.length()) e. compareTo(s1)) f. 51.substring(4)) g. s2.substring(2,10)) h. s1.indexOf('g')) i....

  • Write a Java program for all items in Question Use System.out.println() for each resulting string. Let...

    Write a Java program for all items in Question Use System.out.println() for each resulting string. Let s1 be " Welcome " and s2 be " welcome ". Write the code for the following statements: a. Check whether s1 is equal to s2 and assign the result to a Boolean variable isEqual. b. Check whether s1 is equal to s2, ignoring case, and assign the result to a Boolean variable isEqual. c. Compare s1 with s2 and assign the result to...

  • Programming language: Java m: substring length n: input strings d: Hamming distance (mismatch) I: Number of...

    Programming language: Java m: substring length n: input strings d: Hamming distance (mismatch) I: Number of letters in Sample input string (s1, s2, s3) Strings consists of: A, C, G, and T Example outputs: Generate all possible possibilities of length m(4) using the values A, C, G, and T. EX possibilites: {A,A,A,A A,A,A,C.... G,G,G,G} and find all the possible combinations that have the same sequence with a hamming distance of 1 (only 1 difference) Given n input strings of length...

  • 6. Write a function which combines two strings which are passed as 7. The trimLeft) method remove...

    Note: Please test your output on the console and also avoid the functions below. We were unable to transcribe this image6. Write a function which combines two strings which are passed as 7. The trimLeft) method removes whitespace from the left end of a 8. Write a function which removes whitespace from both ends of the parameters. Mix one character from each string and return the concatenated result. function('ABC','Defg) return ADBeCfg string. Whitespace in this context is all the whitespace...

  • Topics: About Java What is a compiler, and what does it do? Characteristics of the languageStrongly...

    Topics: About Java What is a compiler, and what does it do? Characteristics of the languageStrongly typed and statically typed Everything has a data type & data types must be declared Case sensitive Object oriented System.out.print() vs. System.out.println() How to use the Scanner class to obtain user input Data typesWhat are they? Know the basic types like: int, double, boolean, String, etc. Variables What is a variable? Declarations Initialization Assignment Constants Reserved words like: What is a reserved word? Examples:...

  • how would I complete this code without calling any built-in java collection framework classes like ArrayList,...

    how would I complete this code without calling any built-in java collection framework classes like ArrayList, LinkedList, etc? import java.util.Iterator; class CallStack<T> implements Iterable<T> { // You'll want some instance variables here public CallStack() { //setup what you need } public void push(T item) { //push an item onto the stack //you may assume the item is not null //O(1) } public T pop() { //pop an item off the stack //if there are no items on the stack, return...

  • Can someone help me out with this? You are given a program that receives four lines...

    Can someone help me out with this? You are given a program that receives four lines in the below format, and stores them in str1, str2, str3, and num1. This is not a very long sentence. is long 4 Expand this program to: Write an if-elseif-else statement to print this line only if num1 is higher than 0: "Num1 is higher than 0!" print this line only if num1 is 0: "Num1 equals to 0!" And otherwise, print: ""Num1 is...

  • language is java Restrictions: You are not allowed to use anything from the String, StringBuilder, or...

    language is java Restrictions: You are not allowed to use anything from the String, StringBuilder, or Wrapper classes. In general, you may not use anything from any other Java classes, unless otherwise specified. You are not allowed to use String literals in your code ("this is a string literal"). You are not allowed to use String objects in your code. The methods must be implemented by manipulating the data field array, The CSString Class: NOTE: Pay very careful attention to...

  • I need help modifying this program. How would I make sure that the methods is being...

    I need help modifying this program. How would I make sure that the methods is being called and checked in my main method? Here is what the program needs to run as: GDVEGTA GVCEKST The LCS has length 4 The LCS is GVET This is the error that I'm getting: The LCS has length 4 // I got this right The LCS is   //the backtrace is not being called for some reason c++ code: the cpp class: /** * calculate...

  • Class StringImproved public class StringImproved extends java.lang.Object This program replaces the string class with a mutable...

    Class StringImproved public class StringImproved extends java.lang.Object This program replaces the string class with a mutable string. This class represents a character array and provide functionalities need to do basic string processing. It contains an array of characters, representing a textual string. Overview In Java, Strings are a great device for storing arrays of characters. One limitation of Strings in Java, however (there is always at least one), is that they are immutable (ie. they cannot be changed once created)....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT