Computers and Technology

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.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 17:00, dylancasebere
In microsoft word, you can change the look of paragraphs by:
Answers: 1
image
Computers and Technology, 21.06.2019 21:00, Paulalex8765
Select all that apply. what types of documents can be created using word-processing software? business newsletters letters of application presentation slideshows customer databases
Answers: 1
image
Computers and Technology, 22.06.2019 15:00, misslux
This is not a factor that you should use to determine the content of your presentation. your audience your goals your purpose your technology
Answers: 1
image
Computers and Technology, 23.06.2019 08:30, Bradgarner772
Based on your knowledge of a good network, describe what you think is a perfect network would be. what kind of information and resources could users share on this network. what would the network administrator do? what kind of communication would be used?
Answers: 1
Do you know the correct answer?
Consider the following class declarations. public class Publication
{
private String ti...

Questions in other subjects:

Konu
Mathematics, 09.06.2021 07:20
Konu
Mathematics, 09.06.2021 07:20