Click here to Skip to main content
15,883,901 members
Articles / Web Development / ASP.NET
Article

.NET Bullet Question (small but effective)

Rate me:
Please Sign up or sign in to vote.
1.26/5 (39 votes)
9 Nov 2008CPOL3 min read 36.1K   162   14   15
Small but important questions

Introduction

As a human being it is our tendency that we do not take care for small things. We pay attention to achieve our goal, in-between we miss certain things which will be quite important in our life. Here, I am trying to upload some .Net bullet question .Even though these questions are short; I think it will be effective. I hope this will be helpful for all of us. I will try to keep on adding questions as I get more. If you have some bullet questions to add please send those to me.

.NET Bullet Questions

Are we able to define empty interface (Without any method signature) in .NET?

ANSWER:  Yes, Empty Inter face is possible in .NET.

C#
public partial class EmptyInterFace : System.Web.UI.Page, IEmptyInterface
{
    protected void Page_Load(object sender, EventArgs e)
    {
      Response.Write("Working......... Empty Interface is possible.");
    }
}

interface IEmptyInterface
{
    //Empty Intetrface
}

Is Abstract class being possible without Abstract function?

ANSWER: Yes, Abstract is possible without abstract function in .NET.

C#
public partial class AbstractClass_ : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write(
            "Working.........abstract Class is possible without abstract function.");        
    }
}
// Abstract class without any member function
abstract class MyAbstractClassEmpty
{

}
// Abstract class without Abstract function, having simple member function.
abstract class MyAbstractClassWithFunction
{
    public string MyFun()
    {
        return ("I Enjoyed..........");
    }
}

Is Try & Finally block possible without catch block?

ANSWER: Yes, try and catch block are possible without catch block.

C#
public partial class TryAndFinallyWithoutCatch_ : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // try and finally Block without catch block.
        try
        {
            Response.Write("It's Working..........");
        }
        finally
        {
            Response.Write(" Catch Block Not Necessary With Try & Finally.");
        }
    }
}

Is multiple catch blocks are possible with single try block?

ANSWER: Yes, we can use multiple catch blocks with single try. But for each catch block exception type should be unique. For more see code below:

C#
public partial class MultipleCatchBlockWithSingleTry : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            // We can use it "To Handle different type of Exception."
        }
        catch (ArrayTypeMismatchException ex)
        {
            // Like here we handle ArrayTypeMismatchException exception.
        }
        catch (IndexOutOfRangeException ex)
        {
            // Like here we handle IndexOutOfRangeException exception.
        }
        finally
        {
            Response.Write("Yes, Multiple catch block is possible with 
      single try block.");
        }
 
       /*// It will not Work. 
        try
        {
            //In each Catch Block we need to Mention the Exception type 
            //if we have multiple catch block.
        }
        catch
        {
            //Each Catch block Exception type should be unique
        }
        catch 
        {
            //Each Catch block Exception type should be unique
        }*/
    }
}

What is the way to skip finally block in try, catch Blocks?

ANSWER: No, as per my understanding there is no way to skip finally block in dot net. If you do not want to use finally block no need to right finally block.

C#
public partial class SkipFinallyBlock : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string str = 
            "Even exception occur again in catch block still finally block is Working";
        try
        {            
            throw new IndexOutOfRangeException();
        }
        catch
        {
            throw new IndexOutOfRangeException();
        }
        finally
        {
            Response.Redirect("Error.aspx?str="+ str);
        }
    }
}
Note: While running code if IndexOutOfRangeException will occur please press continue button. Here I want to show even exception come in catch block finally block will work.

How to implement one common function for two interface having same function name with same signature?

ANSWER: See the code below.

C#
public partial class CommonFunctionImplementationForMultipleInterface : 
    System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        myClass obj = new myClass();
        Response.Write(obj.MyFun());
    }
}

 interface MyInterface
{
    String MyFun();
}
interface YourInterface
{
    String MyFun();
}

public class myClass : MyInterface, YourInterface
{
    public String MyFun()
    {
        return ("Wow..... This is Common Method for Multiple Interface");
    }
}

Develope one assembly in C#, assembly contains a class having two functions with same name and same signature but first function name is in lower case and second function name in UPPER CASE. I.e.

C#
public class TestClass
 {
     public string myfunction()
     {
         return ("lower case function");
     }
     public string MYFUNCTION()
     {
         return ("UPPER CASE FUNCTIOM");
     }
 }

Use above assembly in VB.Net and call the CSharp class Hello function. Which function will call (hello or HELLO)?

ANSWER: See the VB.NET code below.

VB
Partial Class CSharpAssemblyUsedInVB
    Inherits System.Web.UI.Page
 
    Dim obj As New SameSignatureFunctions.TestClass
    Dim val As Object 
 
    Protected Sub Page_Load(ByVal sender As Object,
        ByVal e As System.EventArgs) Handles Me.Load
        val = obj.GetType.InvokeMember("myfunction", _
              System.Reflection.BindingFlags.Instance Or _
              System.Reflection.BindingFlags.Public Or System.Reflection.BindingFlags.InvokeMethod, _
              Nothing, obj, Nothing, Nothing, Nothing, Nothing)
        Response.Write(val)
    End Sub
End Class

To Be Continue........

If you have any question which you want to add please mail me Dheerajindian@gmail.com.

Find More VS.NET Question

For more Dot Net Questions your can visit following links.

http://msdotnetsupport.blogspot.com/2007/02/biztalk-server-common-questions-and.html
http://msdotnetsupport.blogspot.com/2007/01/net-interview-questions-by-dutt-part-2.html
http://msdotnetsupport.blogspot.com/2006/08/net-windows-forms-interview-questions.html
http://msdotnetsupport.blogspot.com/2006/08/net-remoting-interview-questions.html
http://msdotnetsupport.blogspot.com/2006/08/c-interview-questions.html
http://msdotnetsupport.blogspot.com/2006/08/aspnet-interview-questions.html
http://msdotnetsupport.blogspot.com/2007/02/net-server-server-adonet-assembly_13.html
http://www.syncfusion.com/faq/aspnet/default.aspx
http://www.aspnetfaq.com
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4081&lngWId=10
http://blogs.crsw.com/mark/articles/254.aspx
http://blog.daveranck.com/archive/2005/01/20/355.aspx
http://www.techinterviews.com/?p=176
http://www.techinterviews.com/?p=193
http://www.dotnetspider.com
http://basittanveer.blogspot.com/2006/05/aspnet-interview-questions.html
http://groups.msn.com/MumbaiUserGroup/aspnetfaqs.msnwx
http://www.c-sharpcorner.com/faq.asp
http://aspalliance.com/891
http://forums.aspfree.com/attachment.php?attachmentid=459
http://forums.aspfree.com/attachment.php?attachmentid=460
http://forums.aspfree.com/attachment.php?attachmentid=461
http://www.toqc.com/entropy/TheAnswers1.html
http://www.toqc.com/entropy/TheAnswers2.html
http://www.akaas.net/jobs/asp-net-interview-questions.htm
http://www.akaas.net/dot-net-faqs.htm
http://www.akaas.net/jobs/asp-net-interview-questions.htm
http://moredotnet.googlepages.com
http://www.interviewcorner.com/
http://www.kyapoocha.com
http://www.coolinterview.com/
http://www.geekinterview.com
http://aspnetinfo.googlepages.com
http://dotnet-question-answer.blogspot.com/
http://vikasnetdev.blogspot.com/2006/06/nice-interview-questions-found-in-job.html
http://www.mytechsky.com
http://www.dotnetquestion.info/dot_net/interview.htm
http://moredotnet.googlepages.com
http://www.coolinterview.com/
http://aspalliance.com/891_Microsoft_NET_Terminologies_at_a_Glance
http://aspalliance.com/929_Operating_Systems_Concepts_and_Terminologies
http://www.techinterviews.com/?p=50
http://www.kyapoocha.com/category/aspnet-interview-questions/
http://dev.fyicenter.com/interview/dotnet.html
http://www.megasolutions.net/kb/ASP_Net_InterView_Questions_1a.aspx

     Happy Job Hunting...........


License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer Hexaware Technologies
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionCan i vote negative Pin
Jacksteseteris22-Oct-08 22:19
Jacksteseteris22-Oct-08 22:19 
AnswerRe: Can i vote negative Pin
dheerajindian22-Oct-08 22:59
dheerajindian22-Oct-08 22:59 
GeneralRe: Can i vote negative Pin
gfoidl22-Oct-08 23:41
gfoidl22-Oct-08 23:41 
GeneralRe: Can i vote negative Pin
Shivprasad koirala23-Oct-08 0:10
Shivprasad koirala23-Oct-08 0:10 
GeneralRe: Can i vote negative Pin
dheerajindian23-Oct-08 0:20
dheerajindian23-Oct-08 0:20 
GeneralRe: Can i vote negative Pin
Maximilian Korporal23-Oct-08 0:39
Maximilian Korporal23-Oct-08 0:39 
AnswerRe: Can i vote negative Pin
Chris Richner9-Nov-08 21:49
Chris Richner9-Nov-08 21:49 
AnswerRe: Can i vote negative PinPopular
Bernhard Elbl10-Nov-08 0:19
Bernhard Elbl10-Nov-08 0:19 
Generalskip finally Pin
Sacha Barber14-Oct-08 9:29
Sacha Barber14-Oct-08 9:29 
GeneralRe: skip finally Pin
dheerajindian14-Oct-08 18:08
dheerajindian14-Oct-08 18:08 
GeneralRe: skip finally Pin
Sacha Barber14-Oct-08 21:52
Sacha Barber14-Oct-08 21:52 
GeneralRe: skip finally Pin
CARPETBURNER22-Oct-08 22:48
CARPETBURNER22-Oct-08 22:48 
GeneralRe: skip finally Pin
PIEBALDconsult23-Oct-08 4:19
mvePIEBALDconsult23-Oct-08 4:19 
GeneralRe: skip finally Pin
gfoidl23-Oct-08 0:00
gfoidl23-Oct-08 0:00 
GeneralRe: skip finally Pin
Kamarey10-Nov-08 20:24
Kamarey10-Nov-08 20:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.