Answered Questions

  • Sub Class method call

    When the Subclass method is called, does the SuperClass constructor execute? If so, which Constructor executes first (Sub Class OR Super Class) for the given below scenarios? a. Given that we are NOT inheriting SuperClass constructor? b. Given that we are inheriting SuperClass constructor?

    Shrimp

    • Apr 1st, 2016

    When a sub class method is called from parent class, constructor will be executed dude, constructor only executed when you create an object

  • What is the use of interface in realtime java project ?

    meena

    • Feb 16th, 2016

    Consider a construction of a building. The basic entire PLAN of the building I what an INTERFACE does. Next, the implementation of that PLAN is done by CONCRETE methods. If some of the work is done and still some is left is what ABSTRACT method/class does.

  • what is the difference between abstract class & Final class

    baban

    • Feb 11th, 2016

    Abstract class cannot create object but final class create a object
    abstract class which have must a subclassed but final class which have no subclassed

  • Can we override the main method?

    Star Read Best Answer

    Editorial / Best Answer

    ashish_setia  

    • Member Since Oct-2006 | Oct 3rd, 2006


    check out this example

    class Checkmain{
    public static void main(String args[]){
    args[1]="ashish";
    System.out.println("hello ");
    }
    }
    class Checkmain1 extends Checkmain{
    public static void main(String args[]){
    System.out.println("how r u");
    }

    }
    class Jo{
    public static void main(String args[]){
    String S[]=new String[10] ;

    Checkmain.main(S);
    Checkmain1.main(S);
    }}

    vivek

    • Aug 26th, 2017

    Yes you can only do that by overriding main method signature for eg main(String[] args) to main(). Certainly there are no other ways to do that because JVM needs strings array arguments to take comma...

    Dharmendra Singh

    • Sep 15th, 2016

    yes we can"java public class HelloWorld { // arguments are passed using the text field below this editor public static void main(String[] args) { String []s =new Str...

  • Why we can not override static method?

    Ramesh

    • Feb 4th, 2016

    If a subclass defines a class method with the same signature as a class method in the superclass, the method in the subclass hides the one in the superclass. You didn't override the method a(), because static methods are not inherited. If you had put @Override, you would have seen an error.