subject

Consider the following class declarations. public class Tree
{
private String treeVariety;
public Tree()
{
treeVariety = "Oak";
}
public Tree(String variety)
{
treeVariety = variety;
}
}
public class DeciduousTree extends Tree
{
public DeciduousTree(String variety)
{
super();
}
}
public class EvergreenTree extends Tree
{
public EvergreenTree(String variety)
{
super(variety);
}
}
The following code segment appears in a method in another class.
DeciduousTree tree1 = new DeciduousTree("Maple");
EvergreenTree tree2 = new EvergreenTree("Fir");
Which of the following best describes the result of executing the code segment?
A: Object tree1 is created using the DeciduousTree constructor, which uses super to set tree1’s treeVariety attribute to "Maple". Object tree2 is created using the EvergreenTree constructor, which uses super to set tree2’s treeVariety attribute to "Fir".
B: Object tree1 is created using the DeciduousTree constructor, which uses super to set tree1’s treeVariety attribute to "Oak". Object tree2 is created using the EvergreenTree constructor, which uses super to set tree2’s treeVariety attribute to "Fir".
C: Object tree1 is created using the DeciduousTree constructor, which uses super to set tree1’s treeVariety attribute to "Oak". Object tree2 is created using the EvergreenTree constructor, which uses super to set tree2’s treeVariety attribute to "Oak".
D: The code segment does not compile because the DeciduousTree and EvergreenTree constructors should not take a parameter.
E: The code segment does not compile because the DeciduousTree and EvergreenTree constructors do not correctly call a Tree constructor.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 19:30
Raveena is making a professional presentation for a newly launched product of her company. she wants to incorporate the following features in her presentation. a) to add serial numbers in each slide b) to add name of her company on top of each slide. c) to add the picture of her product on the second slide(the picture of her product is stored on her computer) write the commands/features of her presentation tool using which she can perform the above operations.
Answers: 2
question
Computers and Technology, 22.06.2019 11:00
What are two of the most common reasons that peolpe who need mental health care do not access it?
Answers: 1
question
Computers and Technology, 23.06.2019 04:31
Acloud service provider uses the internet to deliver a computing environment for developing, running, and managing software applications. which cloud service model does the provider offer? a. iaas b. caas c. maas d. paas e. saas
Answers: 1
question
Computers and Technology, 23.06.2019 19:40
Use a physical stopwatch to record the length of time it takes to run the program. calculate the difference obtained by calls to the method system.currenttimemillis() just before the start of the algorithm and just after the end of the algorithm. calculate the difference obtained by calls to the method system.currenttimemillis() at the start of the program and at the end of the program so that the elapsed time includes the display of the result. use the value returned by the method system.currenttimemillis() just after the end of the algorithm as the elapsed time.
Answers: 3
You know the right answer?
Consider the following class declarations. public class Tree
{
private String treeVarie...
Questions
question
Mathematics, 29.03.2020 13:28
question
Mathematics, 29.03.2020 13:29
question
Mathematics, 29.03.2020 13:29
question
World Languages, 29.03.2020 13:48
question
Computers and Technology, 29.03.2020 13:49
question
Mathematics, 29.03.2020 13:49
Questions on the website: 13722363