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
zavuch27 [327]
3 years ago
6

Given the String variables name1 and name2, write a fragment of code that assigns the larger of the two to the variable first (a

ssume that all three are already declared and that name1 and name2 have been assigned values). (Note: "larger" here means alphabetically larger, not "longer". Thus, "mouse" is larger than "elephant" because "mouse" comes later in the dictionary than "elephant"!)
Computers and Technology
1 answer:
Neporo4naja [7]3 years ago
6 0

Answer:

if ( name1 > name2) {

    first = name1;

} else {

    first = name2;

}

Explanation:

First you need take a decision for that reason you need and if - else structure to decide if asign the variable name1 or the variable name2 to the result. Later you can use an > or < to compare two strings because it use the ASCII code to compare wich one is larger than another.

if ( name1 > name2) {

    first = name1;

} else {

    first = name2;

}

You might be interested in
A batholith is an example of a(n) _____ igneous rock (one of the two main igneous rock groups).
Naily [24]
A batholith is an intrusive igneous rock.
3 0
3 years ago
Read 2 more answers
Reimplement StringSet with the exception that it should now extend ArrayList instead of encapsulating a String[]. You can easily
kolbaska11 [484]

Answer:

Here is the program for the given question

Explanation:

class StringSet

{

ArrayList<String> arraylist; //a reference variable of ArrayList of generic type String

//A no argument constructor.

public StringSet()

{

arraylist=new ArrayList<String>(); //instantiating the ArrayList object

}

//A mutator that adds a String newStr to the StringSet object.

void add(String newStr)

{

arraylist.add(newStr); // add(String) method to add string to the arraylist

}

//An accessor that returns the number of String objects that have been added to this StringSet object.

int size()

{

return arraylist.size(); // size() method which gives the number of elements in the list

}

//An accessor that returns the total number of characters in all of the Strings that have been added to this StringSet object.

int numChars()

{

int sum = 0;

for(String str:arraylist) //for-each loop; can be read as for each string in arraylist

{

sum+=str.length();

}

 

return sum;

}

//An accessor that returns the number of Strings in the StringSet object that have exactly len characters.

int countStrings(int len)

{

int count = 0;

for(String str:arraylist)

{

if(str.length() == len)

count++;

}

return count;

}

}

4 0
3 years ago
What may happen if a large number of computer users are attempting to access a Web site at the same time that you are?
pav-90 [236]
B. You may be unable to link to the site. This is due to a large amount of traffic that the network cannot process. Eg. A large number of students or people trying to get through a small doorway.
5 0
3 years ago
True or false: You buy a new game for your smartphone, and instead of going through the tutorial, you learn how the game works j
stealth61 [152]

Answer: i think it is true because i have  heard of that saying before with my friends i am a pc expert i know lots about them

Explanation: i heard the saying before

4 0
3 years ago
What is the purpose of the green flag in the Scratch interface?
Len [333]

Answer:

C. It begins the program.

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • Flexplace and telecommuting are similar in that both allow you to _____. work in a location away from the office work different
    8·1 answer
  • Prominent is another word for stands out. True False
    13·1 answer
  • A(n) __________ is a set of technologies used for exchanging data between applications and for connecting processes with other s
    14·2 answers
  • How to format the selected range of cells as u.s currency
    6·1 answer
  • PLEASE HELP THIS WAS DUE YESTERDAY AND I DIDN'T GET TO IT IN TIME!!!!!!
    8·1 answer
  • For each obstacle, select the best solution. failing to find other members for a club: failing a class: failing to get the credi
    9·2 answers
  • Which font is most suitable for an academic article on a website? Which is most suitable for casual information?
    5·2 answers
  • What are the two types of electronic components
    15·2 answers
  • Write bubblesort algorithm using random programming language
    13·2 answers
  • What computer is designed for particular application​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!