Examveda

What will be the output of the following C# code?
class maths
{
    public int fun(int ii)
    {
        return(ii > 0 ? ii :ii * -1);
    }
    public long fun(long ll)
    {
        return(ll > 0 ? ll :ll * -1);
    }
    public double fun( double dd)
    {
        return(dd > 0 ? dd :dd * -1);
    }
}    
class Program
{
    static void Main(string[] args)
    {
        maths obj = new maths();
        int i = -25;
        int j ;
        long l = -100000l ;
        long m;
        double d = -12.34;
        double e;
        j = obj.fun(i);
        m = obj.fun(l);
        e = obj.fun(d);
        Console.WriteLine(j + "  " + m + "  " + e);
        Console.ReadLine();
    }
}

A. 1 1 1

B. 0 0 0

C. 25 100000 12.34

D. -25 -100000 -12.34

Answer: Option C


Join The Discussion

Related Questions on Classes and Objects in C Sharp