Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following partial class definitions. public class Membership { private String id; public Membership ( String input ) { id = input; } /

Consider the following partial class definitions.
public class Membership
{
private String id;
public Membership(String input)
{ id = input; }
// Rest of definition not shown
}
public class FamilyMembership extends Membership
{
private int numberInFamily =2;
public FamilyMembership(String input)
{ super(input); }
public FamilyMembership(String input, int n)
{
super(input);
numberInFamily = n;
}
// Rest of definition not shown
}
public class IndividualMembership extends Membership
{
public IndividualMembership(String input)
{ super(input); }
// Rest of definition not shown
}
The following code segment occurs in a class other than Membership, FamilyMembership, or IndividualMembership.
FamilyMembership m1= new Membership("123"); // Line 1
Membership m2= new IndividualMembership("456"); // Line 2
Membership m3= new FamilyMembership("789"); // Line 3
FamilyMembership m4= new FamilyMembership("987",3); // Line 4
Membership m5= new Membership("374"); // Line 5
Which of the following best explains why the code segment does not compile?
Responses
In line 1, m1 cannot be declared as type FamilyMembership and instantiated as a Membership object.
In line 1, m1 cannot be declared as type FamilyMembership and instantiated as a Membership object.
In line 2, m2 cannot be declared as type Membership and instantiated as an IndividualMembership object.
In line 2, m2 cannot be declared as type Membership and instantiated as an IndividualMembership object.
In line 3, m3 cannot be declared as type Membership and instantiated as a FamilyMembership object.
In line 3, m3 cannot be declared as type Membership and instantiated as a FamilyMembership object.
In line 4, m4 cannot be declared as type FamilyMembership and instantiated as a FamilyMembership object.
In line 4, m4 cannot be declared as type FamilyMembership and instantiated as a FamilyMembership object.
In line 5, m5 cannot be declared as type Membership and instantiated as a Membership object.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions