subject

Consider the following class declarations. public class Publication
{
private String title;

public Publication()
{
title = "Generic";
}

public Publication(String t)
{
title = t;
}
}

public class Book extends Publication
{
public Book()
{
super();
}
public Book(String t)
{
super(t);
}
}
The following code segment appears in a method in another class.

Book myBook = new Book("Adventure Story"); // Line 1
Book yourBook = new Book(); // Line 2

Which of the following best describes the result of executing the code segment?

a. Object myBook is created using the one-argument Book constructor, which uses super to set myBook’s title attribute to "Adventure Story". Object yourBook is created using the Book constructor, which uses super to set yourBook’s title attribute to an empty string.
b. Object myBook is created using the no-argument Book constructor, which uses super to set myBook’s title attribute to "Generic". Object yourBook is created using super to call to the Publication no-argument constructor to set yourBook’s title attribute to "Generic".
c. Object myBook is created using the one-argument Book constructor, which uses super to set myBook’s title attribute to "Adventure Story". Object yourBook is created using super to call to the Publication no-argument constructor to set yourBook’s title attribute to "Generic".
d. A runtime error occurs in line 1 because the one-argument Publication constructor cannot be called from the one-argument Book constructor.
e. A runtime error occurs in line 2 because the no-argument Publication constructor cannot be called from the no-argument Book constructor.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 12:00
The following function returns a string of length n whose characters are all 'x'. give the order of growth (as a function of n) of the running time. recall that concatenating two strings in java takes time proportional to the sum of their lengths. public static string f(int n) { if (n == 0) return ""; if (n == 1) return "x"; return f(n/2) + f(n - n/2); } options: a) constant b) logarithmic c) linear d) linearithmic e)quadratic f)cubic g) exponential
Answers: 2
question
Computers and Technology, 22.06.2019 13:30
Asoftware company hired ray, a college graduate to work in their development team. ray is assigned to work in the coding phase of a project. what happens during the coding phase of a software development project? a. the customer receives a working model of the software. b. developers convert the program design into code. c. developers gather requirements directly from the stakeholders. d. testing teams check the product for quality.
Answers: 1
question
Computers and Technology, 22.06.2019 17:00
Acase study allows a more detailed look at the life of a single subject than any other study.
Answers: 3
question
Computers and Technology, 22.06.2019 18:30
Which of the following is an example of intellectual properly! oa. new version of a novelb. journal of ideasc. pages of a bookood. lines of a poem
Answers: 2
You know the right answer?
Consider the following class declarations. public class Publication
{
private String ti...
Questions
question
Geography, 28.01.2021 03:30
question
Mathematics, 28.01.2021 03:30
question
Social Studies, 28.01.2021 03:30
question
Computers and Technology, 28.01.2021 03:30
question
Mathematics, 28.01.2021 03:30
question
Mathematics, 28.01.2021 03:30
Questions on the website: 13722363