Code Snippets in JAVA Programming and their OUTPUTS-Day 1
CODE SNIPPETS OUTPUT
POLYMORPHISM (METHOD OVERLOADING)
Question: Can we overload the main method? Answer: Yes.
public class Test
{
public static void main(String[] args)
{
System.
out.
println("This...
More
Code Snippets in JAVA Programming and their OUTPUTS-Day 1
CODE SNIPPETS OUTPUT
POLYMORPHISM (METHOD OVERLOADING)
Question: Can we overload the main method? Answer: Yes.
public class Test
{
public static void main(String[] args)
{
System.
out.
println("This is from main with String argument");
}
public static void main(char args)
{
System.
out.
println("This is from main with char argument");
}
}
This is from main with
String argument
Concept: Basics of Overloading
public class Test
{
void show(int a)
{
System.
out.
println("Inside int");
}
void show(float f)
{
System.
out.
println("Inside float");
}
public static void main(String[] args)
{
Test t=new Test();
Inside int
Inside float
Less