next


Java Online Compiler
Local Global Varaible
Encapsulation


class Demo
{
int x; //Glabal Varaible
void show()
{
int y=10;//Local Variable
x=100;
System.out.println("x value is "+x);
System.out.println("y value is "+y);
}

void disp()
{
int z=20;//Local Variable
x=200;
System.out.println("x value is "+x);
//System.out.println("y value is "+y);
System.out.println("z value is "+z);
}
}
class LocalGlobal
{
public static void main(String args[])
{
Demo d=new Demo();
d.show();
d.disp();
}
}

							
							

Program for Max Number using NoReturn type with NoParameters
methods

/*Program for Max Number using NoReturn type with NoParameters*/
class MaxNum
{

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

Program for Max Number using NoReturn type with Parameters

/*Program for Max Number using NoReturn type with Parameters*/
class MaxNum
{

void max(int x,int y)
{

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


Program for Max Number using Return type with NoParameters

/*Program for Max Number using Return type with NoParameters*/
class MaxNum
{

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

Program for Max Number using Return type with Parameters

/*Program for Max Number using Return type with Parameters*/
class MaxNum
{

int max(int x,int y)
{

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