steps
1.I create a java project.
2.in the same java project i ll create a main class(say sample).
3.i ll call a function(say sample_function()) inside main class.

question is:

where should i implement the function(sample_function()) i.e
should i have to create a new class in the same project or i should define a new class above main class and implement the function in that class

and in the later case i.e if i create new class in the same project how to call the function in the same class without creating the object of that class in the main class?

From the info you have given the method could be defined in either place.
If you define it in a different class then how you call it depends on whether it's static or not:
If static, call it using the class name, no instance required
If not static, you need an instance of its class to call the method.