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

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

Program
class MaxNumber
{
    int x,y;
    MaxNumber()
    {
        x=10;
        y=20;
    }
    String max()
    {
        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();
        String s=m.max();
        System.out.println(s);
    }
}

Output:

y is Max Number





More Questions


115 . Write a Java-program to print Max Number program using no parametarized constructor with no return type with parametarized method
116 . Write a Java-program to print Max Number program using no parametarized constructor with return type with no parametarized method
117 . Write a Java-program to print Max Number program using no parametarized constructor with return type with parametarized method
118 . Write a Java-program to print Max Number program using no parametarized constructor with no return type with no parametarized method
119 . Write a Java-program to print Max Number program using parametarized constructor with no return type with parametarized method
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