asit mohan nautiyal


{ City } noida
< Country > india
* Profession * software developer
User No # 33607
Total Questions Posted # 0
Total Answers Posted # 2

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 11
Users Marked my Answers as Wrong # 6
Questions / { asit mohan nautiyal }
Questions Answers Category Views Company eMail




Answers / { asit mohan nautiyal }

Question { 12115 }

What is an Exception ?


Answer

An exception is any error condition or unexpected behavior
encountered by an executing progarm othre than logic or
syntex errors.

The error conditions might include conditios such as
division by zero, access to an array to an array outside of
its bounds,etc.

To handle exception we use three statements :
1. try 2. catch 3.finally

Is This Answer Correct ?    7 Yes 6 No

Question { Satyam, 10936 }

How can you prevent classes to be inherited?


Answer

sealed modifier is used for preventing the accident
inhritance of a class. A sealed class can not be inhrited.

Example :

using system;

sealed class abc
{
protected string str = "";

public virtual void hello()
{
str = " Hi i am not in C#";
}
class xyz : abc //--ERROR--
{
public override void hell0()
{
str = "hi i am in C#";
Console.WriteLine("{0}",str);
}
}
class mainclass
{
public static void Main()
{
xyz x = new xyz();
x.hello();
}
}

Note-> if we run above program thn we will get an error
because we inheit class abc while it is sealed.

Is This Answer Correct ?    4 Yes 0 No