Subjects
PRICING
COURSES
SIGN IN
Start Free Trial
Jake A.
Undergraduate at The Ohio State University
Tutor Satisfaction Guarantee
Java Programming
TutorMe
Question:

Complete the following method that converts the stack parameter to a String with the first String in the stack at the front and the last string at the end (ensure that the stack parameter is restored by the end of the method): public static String toString(Stack <String> output) {}

Jake A.
Answer:

Iterative solution: public static String toString(Stack <String> output) { String str = ""; for (String currentString: output) { str = currentString + str; } return str; } Recursive solution: public static String toString(Stack <String> output) { String str = ""; if (output.length()!=0) { String current = output.pop(); str += toString(output); str += current; output.push(str); } return str; }

Chemistry
TutorMe
Question:

Given the following endothermic reaction: N2(g) + 3H2(g) -> 2NH3(g), list three ways to increase the yield of NH3(g).

Jake A.
Answer:

This question is an application of LeChatelier's Principle, the fact that a system under stress will act to reduce the stress on the system. One way to increase the amount of NH3 in the mixture is by decreasing the value of the reaction quotient, Q. To do this, the amount of N2 or H2 can be increased. Increasing reactant pressures causes equilibrium to shift right, forming more NH3 until Q equals the equilibrium constant, K. Another way to increase the amount of NH3 is by increasing temperature. Because the reaction is endothermic, temperature can be viewed as a reactant. By raising temperature, the equilibrium constant will increase to form more NH3. A third way to increase the yield of NH3 is to decrease the volume of the system. To reduce the stress on the system, the system will shift towards less moles of gas. Thus, the system will shift right, towards NH3, as there are less moles of gas on the product side than on the reactant side of the equation.

Computer Science (General)
TutorMe
Question:

Consider the following interface and class declarations: interface Animal { public void eat(String food); public void speak(); } interface Dog extends Animal { public int walk(); } public class Poodle implements Dog { public Poodle() { } public void eat(String food) { System.out.println(food + " has been eaten."); } public void speak() { System.out.println("Aarf!"); } public int walk() { int minutesWalked = (int) Math.Random()*6; return minutesWalked; } } public class MiniPoodle extends Poodle { public MiniPoodle() { } public void speak() { System.out.println("Bark!"); } } If the following code appears in the main method, will the code compile? If so, what will be the output? Poodle p1 = new MiniPoodle(); p1.eat("Pizza"); p1.speak();

Jake A.
Answer:

This question is an application of object-oriented programming, focusing on interfaces, classes, and polymorphism. First off, the code will compile. The Poodle class must contain method definitions for the Animal and Dog interfaces, because Poodle extends Dog (which extends Animal). Furthermore, because the MiniPoodle class extends Poodle, it is valid to have Poodle as the reference type and MiniPoodle as the object type of p1. Next, even though the MiniPoodle class doesn't explicitly define an eat method, it inherits this method from the Poodle class. Inheritance is a key benefit of object-oriented design. Finally, when p1 calls the speak method, it will call the MiniPoodle speak method instead of the Poodle speak method, because MiniPoodle is the object type of p1. Thus, the output will be: Pizza has been eaten. Bark!

Send a message explaining your
needs and Jake will reply soon.
Contact Jake
Ready now? Request a lesson.
Start Session
FAQs
What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Session" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.