somdutt bhai, let me explain u something.
when any member(data member or methods) of a class are accessed outside that class, it requires an object reference bcz non-static data members are allocated memory when any object of the relevant class is created. but static members are allocated memory as soon as the class is created. Therefore, they are considered as class variables. the static members need not any object reference, they can be always called directly by the class itself.
morever, when a static method is called, it doesnt have any object refernce( bcz it has been called directly by class), so it can not call any non-static member directely(bcz non-static members require an object reference). but even though using any other object reference, it can call non-static members also.
lets see ur first program-
class abc
{
int a;
abc(int i)
{
a=i;
}
void dis()
{
System.out.println("a is : " + a);
}
}
class fin{
public static void main(String args[])
{
abc obj = new abc(5);
obj.dis();
}
}
first main() method is called by java run time system without using any object( called directly by class, thats why we have to qualify main() as static). now main() cant call dis() function directly bcz it is non static(it requires an object reference,which main() doesnt have). so it has to create an object of abc class and call dis() using that object.
remember, if dis() had been static, it could have been called by main() like-
abc.dis();
the same explanation is continued for ur second program except that if dis() had been static, it could have been called by main() like-
dis();