Write a Java-program to print Max Number program using parametarized constructor with return type with parametarized method

Write a Java-program to print Max Number program using parametarized constructor with return type with parametarized method

Program
class MaxNumber
{
    int x,y;
    MaxNumber(int p,int q)
    {
        x=p;
        y=q;
    }
    String max(int a,int b)
    {
        if(x>y)
        {
           return("x is Max Number");
        }
        else
        {
            return("y is Max Number");
        }
    }
}
public class Main
{
    public static void main(String args[])
    {
        MaxNumber m=new MaxNumber(10,20);
        String s=m.max(1,2);
        System.out.println(s);
    }
}

Output:

y is Max Number





More Questions


120 . Write a Java-program to print Max Number program using parametarized constructor with return type with no parametarized method
121 . Write a Java-program to print Max Number program using parametarized constructor with return type with parametarized method
122 . Write a Java-program to print Factorial Number program using no parametarized constructor with no return type with no parametarized method
123 . Write a Java-program to print Factorial Number program using no parametarized constructor with no return type with parametarized method
124 . Write a Java-program to print Factorial Number program using no parametarized constructor with return type with no parametarized method
125 . Write a Java-program to print Factorial Number program using no parametarized constructor with return type with parametarized method
126 . Write a Java-program to print Factorial Number program using no parametarized constructor with no return type with no parametarized method
127 . Write a Java-program to print Factorial Number program using parametarized constructor with no return type with parametarized method
128 . Write a Java-program to print Factorial Number program using parametarized constructor with return type with no parametarized method
129 . Write a Java-program to print Factorial Number program using parametarized constructor with return type with parametarized method
130 . Write a Java-program using this.(dot)