Recycling Bin


.NET LINQ Public New

Easy 

5min


Consider the following code:

C#

public class RecyclingBin
{
    protected List<string> recyclables = new List<string>();
    
    public void Add(string recyclable)
    {
        if (recyclable.Split(' ').Length > 1)
        {
            recyclables.Add(recyclable);
        }
    }
    
    public List<IGrouping<string, string>> SortRecyclables()
    {
        return recyclables.GroupBy(recyclable => recyclable.Split(' ').First()).ToList();
    }
}

VB.NET

Public Class RecyclingBin
    Protected recyclables As List(Of String) = New List(Of String)
    
    Public Sub Add(recyclable As String)
        If recyclable.Split(" ").Length > 1
            recyclables.Add(recyclable)
        End If
    End Sub

    Public Function SortRecyclables()
        Return recyclables.GroupBy(Function(recyclable) recyclable.Split(" ").First()).ToList()
    End Function
End Class

Select the statements that are true if a new RecyclingBin is instantiated and the Add method is called with the following recyclable parameters: "metal pipe", "plastic toy", "metal bar", "copper wire", and "plastic button".

(multiple correct answers possible)