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 the buffer limit?
What is arraylist class in java?
What is the base class for error and exception?
Which command from the jdk compiles a java program?
Why do we need wrapper class?
Is treeset sorted in java?
Define locale.
What is Java Reflection API? Why it’s so important to have?
Why is string class considered immutable?
Is {a, n, d} a palindrome? If you are given a random string, is it a palindrome or not?
What is difference between word and integer?
Explain yield() method in thread class ?
What is a stack class in java ?
how to create daemon thread in java?
What is a java object and java application?