Try to solve 5 .NET interview questions below. Hints can help you find answers to questions you are having trouble with.

1. Integer

Class library
   
Easy  

Which statements are true for an int/Integer built in .NET data type?

(Select all acceptable answers.)

It supports bitwise operators.
On a 64bit system, it can contain the number 2^48.
The ToString method can be used for formatting a numerical value.
The expression a/b will return infinity if a has value 1 and b has value 0.
It is unsigned by default and does not support negative values.
   


2. Inheritance

Class modifiers Method modifiers OOP
   
Easy 

A class inherits a base class and it overrides a method from that base class.

Select all possible forms of the base class and its method:

(Select all acceptable answers.)

The base class can be sealed in C# (NotInheritable in Visual Basic).
The base class can be abstract in C# (MustInherit in Visual Basic).
The method from the base class can be abstract in C# (MustOverride in Visual Basic).
The method from the base class can be virtual in C# (Overridable in Visual Basic).
The method from the base class does not need to have any modifier.
The method from the base class can have only a protected modifier.
The method in the overriding class must have the override (Overrides in Visual Basic).
   


3. Parsing XML

Class library Serialization XML
   
Hard 

Which statements are true for the .NET technologies you can use to process XML data?

(Select all acceptable answers.)

System.Xml.XmlReader.Create(Stream stream) builds an internal model that holds the whole XML file.
System.Xml.Linq.XElement can be used to modify the existing XML file.
Using System.Xml.Serialization.XmlSerializer can be used when the XML stream is expected to conform to a known XML schema.
System.Xml.Linq.XElement.Load(Stream stream) builds an internal model that holds the whole XML file.
Executing System.Xml.Linq.XElement.Load(Stream stream) is faster than executing System.Xml.XmlReader.Create(Stream stream).
   


4. Crab Inheritance

Method overriding OOP
   
Easy 

Consider the following code:

C#

public class Crab 
{
    public virtual string PinchClaws()
    {
        return "clap clap";
    }
}

public class CoconutCrab : Crab
{
    public override string PinchClaws()
    {
        return "CLAP CLAP";
    }
}

VB.NET

Public Class Crab
    Public Overridable Function PinchClaws() As String
        Return "clap clap"
    End Function
End Class

Public Class CoconutCrab
Inherits Crab
    Public Overrides Function PinchClaws() As String
        Return "CLAP CLAP"
    End Function
End Class

Select the statements that are correct.

(Select all acceptable answers.)

Calling PinchClaws() on an instance of CoconutCrab will return "CLAP CLAP".
Calling PinchClaws() on an instance of Crab will return "CLAP CLAP".
Casting an instance of CoconutCrab into Crab and then calling the PinchClaws method will return "clap clap".
Casting an instance of Crab into CoconutCrab will throw an exception.
   


5. Recycling Bin

LINQ
   
Easy  

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", "plastic button", and "brass".

(Select all acceptable answers.)

One of the groups returned from SortRecyclables will have "metal" as its key and will contain "metal bar" and "metal pipe".
One of the groups returned from SortRecyclables will have "wire" as its key and will contain "copper wire".
The List returned from SortRecyclables will not be evaluated in the SortRecyclables method.
The Add method will add a new recyclable only if it contains a space.
   


If you feel ready, take one of our timed public .NET Interview Questions tests:
C#

C# and .NET Online Test (Easy / Hard)

VB.NET

VB.NET and .NET Online Test (Easy / Hard)

Not exactly what you are looking for? Go to our For Jobseekers section.