01.java
// Static and non-static componentsclass One
{
static int n;
static void show()
{
System.out.println("This is a static method");
}
One(int a,int b)
{
System.out.println("Addition of two numbers");
c=a+b;
System.out.println("Sum of two numbers "+c);
}
int a,b;
int c;
void display()
{
int d=50;
System.out.println("Sum :"+c);
System.out.println("D value :"+d);
}
}
class TestOne
{
public static void main(String ar[])
{
One.show(); //Static method show being called using its class name "One"
System.out.println(one.n);
One ob1=new one(20,40);
One ob2;
System.out.println(ob1);
ob1.display();
ob2=new one(30,50);
ob2.show(); //We can also call show method using objects
}
}