Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Can we override the main method?

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


Please Help Members By Posting Answers For Below Questions

Can arraylist contain null values?

1015


Difference between this() and super() ?

1109


How do you test a method for an exception using junit?

1208


Write a method to check if input string is palindrome?

1019


What are the core java topics?

1041


What is assembly language?

981


What does microservices mean?

949


What is immutable in java?

1063


What is the basic concept of java?

1008


Why is java logo a cup of coffee?

1167


What happens if a constructor is declared private?

1034


Why is the singleton pattern considered to be an anti pattern?

884


What advantage do java's layout managers provide over traditional windowing systems?

953


How do you compare two strings lexicographically?

934


What is the Concept of Encapsulation in OOPS

995