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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 15:00, yeet74
I'm taking a class on how to make a movie, and it offers some apps that would be in the process. the thing is, i don't have any of those ha. if you have any tips on some apps i could use, that would be awesome. i don't have an iphone, so don't suggest any apps like imovie. i know that this is a weird question, but it would be super for me. : )
Answers: 2
image
Computers and Technology, 23.06.2019 23:30, issacurlyheadka
A. in packet tracer, only the server-pt device can act as a server. desktop or laptop pcs cannot act as a server. based on your studies so far, explain the client-server model.
Answers: 2
image
Computers and Technology, 24.06.2019 14:00, superstarsara5ouh83x
Fast answer i need for apex ! smartphones should be banned from the classroom in public schools so that students cannot cheat on test so easily? which is an example of a counter argument to the thesis above? a. the classroom is a place for learning not for making phone calls b. smartphones are useful learning tools in the modern classroom c. banning smartphones will not students pay attention to teachers any better d. banning smartphones would decreased incidents of theft
Answers: 2
image
Computers and Technology, 25.06.2019 01:00, shonesam98
Regular maintenance is a key component of automotive lift safety.
Answers: 1
You know the right answer?
Consider the following class declarations. public class Tree
{
private String treeVarie...

Questions in other subjects:

Konu
Mathematics, 20.09.2019 01:30
Konu
Mathematics, 20.09.2019 01:30
Konu
Mathematics, 20.09.2019 01:30