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
{
}
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 MyAbstractClassEmpty
{
}
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
{
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
{
}
catch (ArrayTypeMismatchException ex)
{
}
catch (IndexOutOfRangeException ex)
{
}
finally
{
Response.Write("Yes, Multiple catch block is possible with
single try block.");
}
}
}
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...........