User
Consider the following class declarations.
public class Dog
{
private String name;
public Dog()
{
name = "NoName";
}
}
public class Poodle extends Dog
{
private String size;
public Poodle(String s)
{
size = s;
}
}
The following statement appears in a method in another class.
Poodle myDog = new Poodle("toy");
Which of the following best describes the result of executing the statement?
Responses
A
The Poodle variable myDog is a reference to an instantiated Poodle object. The instance variable size is initialized to "toy". The instance variable name is not assigned a value.
B
The Poodle variable myDog is a reference to an instantiated Poodle object. The instance variable size is initialized to "toy". An implicit call to the no-argument Dog constructor is made, initializing the instance variable name to "NoName".
C
The Poodle variable myDog is a reference to an instantiated Poodle object. The instance variable size is initialized to "toy". An implicit call to the no-argument Dog constructor is made, initializing the instance variable name to "toy".
D
A runtime error occurs because super is not used to call the no-argument Dog constructor.
E
A runtime error occurs because there is no one-argument Dog constructor.