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:...

  • 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...

  • Need to code the HeapSort Algorithm in java. Most of the code is already done just...

    Need to code the HeapSort Algorithm in java. Most of the code is already done just need to code the "heapify" part of the heapsort algorithm. My heapify code is in bold below called "sink", but when I run it it gives me 2 errors with the string compare part saying: WordCountHeap.java:61: error: cannot find symbol         if(l < k && String.Compare(pq[l], pq[n]) < 0)                           ^ symbol:   method Compare(String,String) location: class String Please fix the code and the "heapify"...

  • 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...

  • Trying to make an autocomplete java program that given a prefix, find all strings in set...

    Trying to make an autocomplete java program that given a prefix, find all strings in set that start with said prefix, in descending weight order. I created the classes Term.java, BinarySearchDeluxe.java, and Autocomplete.java posted below. I believe Term.java is correct, but where you see "//?" needs added code. I will also list before the code, the descriptions of said methods with "//?" to explain their purpose. DO NOT add more import packages or change the main methods as that is...

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