Tokens in Java
There are different types of tokens in java like Identifiers, Operators and Keywords
Identifiers: Identifiers are used in naming the classes, methods, variables, objects, labels, packages and interfaces in a java program. The identifiers are programmer created tokens.
For example: Variable like ‘sum’.
According to homework answers websites java programming language has reserved about 50 keywords. It is an important part of java. Keywords have got a specific meaning in java programming language. They cannot be used as class name, variable name, and method name.
For example: There are various keywords like ‘abstract’, ‘finally’, ‘default’, etc.
Operators: In Java there is wide range of operators. Operator specifies the operation to be performed by a mathematical or logical operation. They are used in a program to operate data and variables. Different categories of operators are as follows:
i. Arithmetic operators:
According to studydaddy they are used to make mathematical expressions working in algebra. Java provides the fundamental arithmetic operators (‘+’ Addition, ‘-’ Subtraction, ‘*’ Multiplication, ‘/’ Division, ‘%’ modulus or remainder).
ii. Logical operators:
Logical operator is used where we have to form a compound condition combining two or more relations.Java provides logical operators like ‘|| ’(Logical OR), ‘&&’ (Logical AND), ‘!’ (Logical NOT).
iii. Bit Wise Operators:
They execute single bit of their operands. Bitwise Operators are ‘|’ (Bitwise OR), ‘&’ (Bitwise AND), ‘~’ (One’s Compliment).
Overloading the Main method in Java
" Can we overload the main method in Java ? "
This is the most interesting question in Java Interviews. As we know the JVM starts execution of the program main method. Main method is the entry point for the Java code for execution.
Like the other method in the Java we can Overload the "main" method too. We can Overload the main method by changing the arguments.
In the above code the we have overloaded the main method by changing the arguments of each method. But as we said earlier main method is the entry point for the JVM to execute the Java code. So how this is managed by the JVM.
In this case JVM calls the standard main method present in the class. JVM never calls the overloaded main method in the class. Every time execution of program is started from the standard main method, if we want to call the overloaded main method in the class we have to call them from the standard main method. We cannot call the overloaded main method directly.