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
Can arraylist contain null values?
Difference between this() and super() ?
How do you test a method for an exception using junit?
Write a method to check if input string is palindrome?
What are the core java topics?
What is assembly language?
What does microservices mean?
What is immutable in java?
What is the basic concept of java?
Why is java logo a cup of coffee?
What happens if a constructor is declared private?
Why is the singleton pattern considered to be an anti pattern?
What advantage do java's layout managers provide over traditional windowing systems?
How do you compare two strings lexicographically?
What is the Concept of Encapsulation in OOPS