Answer to Question #339826 in C# for asha

Question #339826

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
Expert's answer
2022-05-14T16:42:22-0400
(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");
            }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS