Computers and Technology

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.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 12:40, Rententen3845
How do i get the most points, without any effort?
Answers: 2
image
Computers and Technology, 23.06.2019 12:40, Emilyvite6251
According to the video what are some tasks petroleum engineers perform check all that apply
Answers: 2
image
Computers and Technology, 24.06.2019 07:40, daebreonnakelly
What type of multimedia are live news feeds? live news feeds are examples of multimedia.
Answers: 2
image
Computers and Technology, 24.06.2019 13:30, yola32
What is the most important for you to choose before you build a network?
Answers: 1
Do you know the correct answer?
Consider the following class declarations. public class Tree
{
private String treeVarie...

Questions in other subjects:

Konu
Mathematics, 12.03.2021 19:50
Konu
English, 12.03.2021 19:50
Konu
Mathematics, 12.03.2021 19:50
Konu
Mathematics, 12.03.2021 19:50