Menu

[Solved]Java Question Page 317 715 Public Interface Nameable Public Void Setname String Name Publi Q37174576

Java Question:

Write a class called Tree which has a single instance variable called variety of type String. For example, a variety of tree

Page 317 #7.15:

public interface Nameable
{
public void setName(String name);
public String getName();
}

Write a class called Tree which has a single instance variable called variety of type String. For example, a variety of tree could be “maple”. Tree has a constructor with one parameter and a toString method. Write a tester class which creates a Tree object and prints it out Do self-review question 7.15 on p. 317 only the following change Make o Tree. Replace public class Tree with: public class Tree implements Nameable Try compiling your code. It should not compile. -Add a minimum amount of methods to Tree so that it compiles. Update the tester class to test the new code. Show transcribed image text Write a class called Tree which has a single instance variable called variety of type String. For example, a variety of tree could be “maple”. Tree has a constructor with one parameter and a toString method. Write a tester class which creates a Tree object and prints it out Do self-review question 7.15 on p. 317 only the following change Make o Tree. Replace public class Tree with: public class Tree implements Nameable Try compiling your code. It should not compile. -Add a minimum amount of methods to Tree so that it compiles. Update the tester class to test the new code.

Expert Answer


Answer to Java Question: Page 317 #7.15: public interface Nameable { public void setName(String name); public String getName(); } … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *