Identify errors in the following program.After identification make correction and write correct code again
(1)
namespace FirstSessional1
{
interface MyInterface{
string name;
public void Function1();
void Function2() {Console.WriteLine("Function 2");}
}
Class Employee:MyInterface{
void Function1() { }
static void Main(string[] args)
{
MyInterface obj=MyInterface();
}
}
}
(2)
byte a=300,b=500,result;
try
{
r=a+b;
MessageBux.Display("A+B" +r);
}
catch(Exception err)
{
MessageBux.Display("Handle Exception");
}
catch(ArithmeticException ex)
{
MessageBux.Display("Handle Arithmetic Exception);
}
(1)
interface MyInterface
{
void Function1();
void Function2();
}
class Employee : MyInterface
{
string name;
public void Function1()
{
throw new NotImplementedException();
}
public void Function2()
{
Console.WriteLine("Function 2");
}
}
static void Main(string[] args)
{
Employee obj = new Employee();
}
(2)
int a = 300, b = 500, result;
try
{
result = a + b;
MessageBox.Show($"A+B + {result}");
}
catch (ArithmeticException ex)
{
MessageBox.Show("Handle Arithmetic Exception");
}
catch (Exception err)
{
MessageBox.Show("Handle Exception");
}
Comments
Leave a comment