1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
telo118 [61]
3 years ago
6

1. Print out the string length of s1 2. Loop through characters in s2 with charAt() and display reversed string 3. Compare s2, s

3 with compareTo(), print out which string (s2 or s3) is greater than which string (s2 or s3), or equal, print the result out 4. Use the regionMatches to compare s2 and s3 with case sensitivity of the first 8 characters and print out the result (match or not) . 5. Find the location of the first character 'g' in s1, print it out 6. Find the last location of the substring "class" from s2, print it out
Computers and Technology
1 answer:
konstantin123 [22]3 years ago
7 0

Answer:

See explaination

Explanation:

public class StringLab9 {

public static void main(String args[]) {

char charArray[] = { 'C', 'O', 'S', 'C', ' ', '3', '3', '1', '7', ' ', 'O', 'O', ' ', 'C', 'l', 'a', 's', 's' };

String s1 = new String("Objected oriented programming language!");

String s2 = "COSC 3317 OO class class";

String s3 = new String(charArray);

// To do 1: print out the string length of s1

System.out.println(s1.length());

// To do 2: loop through characters in s2 with charAt and display reversed

// string

for (int i = s2.length() - 1; i >= 0; --i)

System.out.print(s2.charAt(i));

System.out.println();

// To do 3: compare s2, s3 with compareTo(), print out which string (s2 or s3)

// is

// greater than which string (s2 or s3), or equal, print the result out

if (s2.compareTo(s3) == 0)

System.out.println("They are equal");

else if (s2.compareTo(s3) > 0)

System.out.println("s2 is greater");

else

System.out.println("s3 is greater");

// To do 4: Use the regionMatches to compare s2 and s3 with case sensitivity of

// the first 8 characters.

// and print out the result (match or not) .

if (s2.substring(0, 8).compareTo(s3.substring(0, 8)) == 0)

System.out.println("They matched");

else

System.out.println("They DONT match");

// To do 5: Find the location of the first character 'g' in s1, print it out

int i;

for (i = 0; i < s2.length(); ++i)

if(s2.charAt(i)=='g')

break;

System.out.println("'g' is present at index " + i);

// To do 6: Find the last location of the substring "class" from s2, print it

// out

int index = 0, ans = 0;

String test = s2;

while (index != -1) {

ans = ans + index;

index = test.indexOf("class");

test = test.substring(index + 1, test.length());

}

System.out.println("Last location of class in s2 is: " + (ans + 1));

// To do 7: Extract a substring from index 4 up to, but not including 8 from

// s3, print it out

System.out.println(s3.substring(4, 8));

} // end main

} // end class StringLab9

You might be interested in
"If someone really wants to get at the information, it is not difficult if they can gain physical access to the computer or hard
Jobisdone [24]

Answer:

It is  just true in most cases

Explanation:

This statement is just true in most cases because in some cases having a physical access to the computer or hard drive this does not guarantee access to the information contained in the hard drive or computer because the data/information in the hard drive or computer might as well be encrypted and would require a password in order to de-crypt the information.

Having a physical access is one step closer in some cases but not the only step required .

4 0
3 years ago
Sometimes a virus will disable a system’s antivirus protection or add exceptions which prevent its being detected. Running an an
nikklg [1K]

Answer:

A boot-up CD or a USB

Explanation:

6 0
3 years ago
You can access various sites on the WWW by using hyperlinks or by
Vilka [71]
<span>or by following directions on screen </span>
5 0
3 years ago
As our use of the internet increases e-safety becomes essential.<br> Discuss why e-safety is needed.
nlexa [21]

Answer:

The answer is described below

Explanation:

E safety means means protection of private information and personal safety when using the internet. E safety involve the protection of private information, passwords against identity theft or property theft. A persons  private information, passwords can be gotten through the use of phishing or malwares.

Also, the use of internet has exposed people to cyber bullying(i.e abuse of an individual), stalking, engaging underage children into sexual relationships and sextortion.

E safety  help protect children from harmful content and services as those listed.

8 0
3 years ago
A queue processes elements in a _____ manner. <br> a. filo <br> b. lifo <br> c. lilo <br> d. fifo
sladkih [1.3K]

A queue processes elements in a <u> fifo</u> manner.

<h3>What is the rule that each stack and queue are understood by?</h3>

The rule used for a queue is to permanently remove the item that has been in the collection the most amount of time.

This policy is known as first-in-first-out or FIFO. The rule used for a stack is to always remove the item that has been in the collection the least amount of time.

<h3>What is queue how it is distinct from stack and how is it implemented?</h3>

The primary difference between Stack and Queue Data Structures is that Stack pursues LIFO while Queue follows FIFO data structure type. LIFO guides to Last In First Out. It means that when we put data in a Pile, it processes the last entry first. Conversely, FIFO guides to First In First Out

To learn more about FIFO,  refer

brainly.com/question/27952133

#SPJ4

3 0
2 years ago
Other questions:
  • The pseudoinstructions that are available in an assembly language programming environment usually found in the Select one: a. CP
    6·1 answer
  • Which of the following savings vehicles usually requires a high minimum balance
    14·1 answer
  • You are given n sorted sequences each one containing n keys. You may assume n is a power of two. We want to merge them into one
    15·1 answer
  • Forensic computer investigators must _____.
    6·2 answers
  • What is computer engineering in your own words?
    8·1 answer
  • Union Carbide accident safety policies and procedures were not followed was due to
    14·1 answer
  • Joel has left his computer unattended while answering a phone call. A TV repairer in his house tries to surf through the applica
    13·1 answer
  • Choose all that apply.
    5·2 answers
  • Jasmine plays a game on her computer screen. A moving balloon appears on the screen, and she has to pop the balloon by clicking
    10·1 answer
  • Presentations must have what to be efffective
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!