Click here to Skip to main content
Licence CPOL
First Posted 14 Oct 2008
Views 14,903
Downloads 57
Bookmarked 14 times

.NET Bullet Question (small but effective)

By | 9 Nov 2008 | Article
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.

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.

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.

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:

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.

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.

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.

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.

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)

About the Author

dheerajindian

Web Developer
Hexaware Technologies
India India

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionCan i vote negative PinmemberJacksteseteris22:19 22 Oct '08  
AnswerRe: Can i vote negative Pinmemberdheerajindian22:59 22 Oct '08  
GeneralRe: Can i vote negative Pinmembergfoidl23:41 22 Oct '08  
GeneralRe: Can i vote negative PinmemberShivprasad koirala0:10 23 Oct '08  
GeneralRe: Can i vote negative Pinmemberdheerajindian0:20 23 Oct '08  
GeneralRe: Can i vote negative PinmemberMaximilian Korporal0:39 23 Oct '08  
AnswerRe: Can i vote negative PinmemberChris Richner21:49 9 Nov '08  
AnswerRe: Can i vote negative PinPopularmemberBernhard Elbl0:19 10 Nov '08  
Generalskip finally PinmvpSacha Barber9:29 14 Oct '08  
GeneralRe: skip finally Pinmemberdheerajindian18:08 14 Oct '08  
GeneralRe: skip finally PinmvpSacha Barber21:52 14 Oct '08  
GeneralRe: skip finally PinmemberGriffinPeter22:48 22 Oct '08  
GeneralRe: skip finally PinmemberPIEBALDconsult4:19 23 Oct '08  
GeneralRe: skip finally Pinmembergfoidl0:00 23 Oct '08  
GeneralRe: skip finally PinmemberKamarey20:24 10 Nov '08  

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

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

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120517.1 | Last Updated 10 Nov 2008
Article Copyright 2008 by dheerajindian
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid