Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

definition of a public static method..?

For the skilled computer programmers out there:

this is a relatively easy code, I am a beginning programmer & would greatly appreciate some help in defining this public static method:

The public static method runForAWhile inputs a Startable object and an int n, and then

calls its start method;

calls its step method n times; and finally

calls its stop method.

Complete the following definition of runForAWhile:

public class MainClass

{

//what comes next?

2 Answers

Relevance
  • Anonymous
    1 decade ago

    I am sure I could help but the problem is not clear. "Startable object" tells me there is a class named Startable. So with the limited info here is what I think you are trying. This will not compile unless you define a Startable class.

    public class MainClass

    {

    -----public static void main( String [] args )

    -----{

    -----------Startable obj = new Startable( ); //instantiate Startable object

    -----------int n = 5;

    -----------runForAWhile( obj, n );

    -----}

    -----public static runForAWhile( Startable obj, int n)

    -----{

    --------------obj.start( ); //start method of Startable class

    --------------obj.step( n ); //step method of Startable class

    --------------obj.stop( ); //stop method of Startable class

    -----}

    }

    Source(s): I'm a Computer Science teacher
  • 1 decade ago

    public static void Main(string[] args)

    {

    Out.println("I don't have time to do my homework.");

    Out.println("Please give me an 'F' and put me out of my misery ...");

    Out.println("... or I'll keep trying to get strangers to do my homework for me forever.");

    }

    }

Still have questions? Get your answers by asking now.