1.An java program with Constructor and method overloading
public class Workout {
public void workout(){
System.out.println("Constructor in Workout");
}
public Workout(){
Workout.main("hi");
System.out.println("Over loaded constructor in Workout");
} public static void main(String string) {
System.out.println(string);
new Workout();
}
public static void main(Integer args[])
{
Workout.main("hi");
}
public static void main(String args[])
{
new Workout();//An program with constructor and method overloading......by k.saravanan
// program for educational purposes only.. Dont copy and post in your blog or ur website ....
}
}
What is output?
Prints hi continuously and stack overflow error will occur.....
public class Workout {
public void workout(){
System.out.println("Constructor in Workout");
}
public Workout(){
Workout.main("hi");
System.out.println("Over loaded constructor in Workout");
} public static void main(String string) {
System.out.println(string);
new Workout();
}
public static void main(Integer args[])
{
Workout.main("hi");
}
public static void main(String args[])
{
new Workout();//An program with constructor and method overloading......by k.saravanan
// program for educational purposes only.. Dont copy and post in your blog or ur website ....
}
}
What is output?
Prints hi continuously and stack overflow error will occur.....
No comments:
Post a Comment
Please post your comments. Your comments make us to write more programs for you.