Method overloading,overriding and static

public class Test {
public static void test() {
print();
}
public static void print() {
System.out.println("Test");
}
public void print() {
System.out.println("Another Test");
}
}

So this code will not work stating – duplicate method error.

Overloading vs Overriding

In case of overloading in java, it doesn’t matter what is the return type of the method. What matters is the name of the method should be same, and their signatures should be different. But in case of overriding even there return types must match.

Which of the following is a legal return type of a method overloading the following
method:

public void add(int a) {…}

A. void
B. int
C. Can be anything
Select the most appropriate answer.(Answer you know is C)

Which of the following is a legal return type of a method overloading the following
method:

public void add(int a) {…}

A. the overriding method must return void
B. the overriding method must return int
C. the overriding method can return whatever it likes
Select the most appropriate answer.(answer you know is A)

Functions or Methods in java

Class behaviour are represented in Java by methods. To declare a method use the following syntax:

[ "public" | "private" | "protected" ] [ "final" ]
[ "static" | "abstract" | "native" ]
return_data_type method_name "(" parameter_list ")"
"{"
// some defining actions
"}"

Accessibility keywords are the same as for properties. The default (ie. omitted) is package (aka friendly) or visible within the current package only.
static methods are shared by all members and exist for all runtime. Static methods can be referenced without creating an instance of the class. abstract methods must be redefined on inheritance. native methods are written in C but accessible from Java.
The return_data_type defines the type of value that the calling routine receives from the object (the reply message in object terminology). It can be any of the primitive types or the reserved word void (default value) if no message is to be returned. The statement return varName; is used to declare the value to be returned to the calling routine.
The parameter_list can contain from zero to many entries of datatype varName pairs. Entries are separated by commas. Parameters are passed by value, thus upholding the encapsulation principle by not allowing unexpected changes or side effects. Object references (such as arrays) can also be passed.
Some examples of method header parameter lists are:

 
public static void example1() {}
public static int add2(int x) {x+=2; return x;}
public static double example3(int x, double d) {return x*d;}
public static void example4(int x, int y, boolean flag) {}
public static void example5(int arr[]) {} // note: this is object

Note: Differences from cpp 
Types of methods
Pass by value or reference