next


Java Online Compiler
Constructor Program
Data abstruction


class MaxNum
{

MaxNum()
{
int x=10;
int y=20;

if(x>y)
{
System.out.println("Max Value is "+x);
}
else
{
System.out.println("Max Value is "+y);
}
}
}
class Const
{
public static void main(String args[])
{
MaxNum m=new MaxNum();

}
}

Program for Max Number using NoReturn type with NoParameters With NoParameters Constructor
Constructor


class MaxNum
{
int x,y;
MaxNum()
{
x=10;
y=20;
}
void max()
{

if(x>y)
{
System.out.println("x is max");
}
else
{
System.out.println("y is max");
}
}
}
class NortWithNopNopc
{
public static void main(String args[])
{
MaxNum m=new MaxNum();
m.max();
}
}

Program for Max Number using NoReturn type with Parameters With NoParametarized Constructor


class MaxNum
{
int x,y;
MaxNum()
{
x=30;
y=20;
}
void max(int a,int b)
{

if(x>y)
{
System.out.println("x is max");
}
else
{
System.out.println("y is max");
}
}
}
class NortWithpNopc
{
public static void main(String args[])
{
MaxNum m=new MaxNum();
m.max(100,200);
}
}

Program for Max Number using Return type with NoParameters With NoParametarized Constructor


class MaxNum
{
int x,y;
MaxNum()
{
x=30;
y=20;
}
int max()
{

if(x>y)
{
return x;
}
else
{
return y;
}
}
}
class RtWithNopNopc
{
public static void main(String args[])
{
MaxNum m=new MaxNum();
int p=m.max();
System.out.println("Max Value is "+p);
}
}

Program for Max Number using Return type with Parameters With NoParametarized Constructor


class MaxNum
{
int x,y;
MaxNum()
{
x=30;
y=20;
}
int max( int a,int b)
{

if(x>y)
{
return x;
}
else
{
return y;
}
}
}
class RtWithpNopc
{
public static void main(String args[])
{
MaxNum m=new MaxNum();
int p=m.max(100,200);
System.out.println("Max Value is "+p);
}
}

Program for Max Number using NoReturn type with NoParameters With Parametarized Constructor


class MaxNum
{
int x,y;
MaxNum(int a,int b)
{
x=30;
y=20;
}
void max()
{

if(x>y)
{
System.out.println("Max Value is "+x);
}
else
{
System.out.println("Max Value is "+y);
}
}
}
class NoRtWithNoppc
{
public static void main(String args[])
{
MaxNum m=new MaxNum(1000,2000);
m.max();

}
}

Program for Max Number using NoReturn type with Parameters With Parametarized Constructor
                      

class MaxNum
{
int x,y;
MaxNum(int a,int b)
{
x=30;
y=20;
}
void max(int p,int q)
{

if(x>y)
{
System.out.println("Max Value is "+x);
}
else
{
System.out.println("Max Value is "+y);
}
}
}
class NoRtWithppc
{
public static void main(String args[])
{
MaxNum m=new MaxNum(1000,2000);
m.max(100,200);

}
}

Program for Max Number using Return type with NoParameters With Parametarized Constructor


class MaxNum
{
int x,y;
MaxNum(int a,int b)
{
x=30;
y=20;
}
int max()
{

if(x>y)
{
return x;
}
else
{
return y;
}
}
}
class RtWithNoppc
{
public static void main(String args[])
{
MaxNum m=new MaxNum(1000,2000);
int s=m.max();
System.out.println("Max Value is "+s);
}
}

Program for Max Number using Return type with Parameters With Parametarized Constructor


class MaxNum
{
int x,y;
MaxNum(int a,int b)
{
x=30;
y=20;
}
int max(int p,int q)
{

if(x>y)
{
return x;
}
else
{
return y;
}
}
}
class RtWithppc
{
public static void main(String args[])
{
MaxNum m=new MaxNum(1000,2000);
int s=m.max(100,200);
System.out.println("Max Value is "+s);
}
}