Answer Posted / sadikhasan palsaniya
Yes we can override main method that explain by following Code.
public class DemoOverride {
public static void main(String string[]){
System.out.println("I am in Main method of super class");
String str[]={"sadik","palsnaiya"};
Over1.main(str);
Over2.main(str);
}
}
class Over1 extends DemoOverride{
public static void main(String str[]){
System.out.println("I am in Main method of Middle
class");
}
}
class Over2 extends Over1{
public static void main(String str[]){
System.out.println("I am in Main method of Child class");
}
}
| Is This Answer Correct ? | 8 Yes | 1 No |
Post New Answer View All Answers
What is static in java?
What is static variable with example?
What are the differences between heap and stack memory in java?
What is string :: npos?
How many types of literals are there in JAVA?
What are different data types?
Explain the usage of this with constructors?
Can we write class inside a class in java?
Is nan false?
What is scope & storage allocation of global and extern variables? Explain with an example
What do you know about the garbage collector in java?
What are the different access modifiers available in java?
Why string is immutable with example?
What is a class component?
What is the maximum size of hashmap in java?