Question

Let's create a void method and call it from main. Here is what to do. Write...

Let's create a void method and call it from main. Here is what to do.

  1. Write a void method that does not take any parameters called printFavorite. It should print your name and a favorite (subject, book, movie, etc) of yours.
  2. Call the method from main.

Run and test it.

For IDEs: Submit your .java file and a screenshot of the output of your code.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
public class Favorite {

    public static void printFavorite() {
        System.out.println("Name: Critiano Ronaldo");
        System.out.println("Favorite Subject: Computer Science");
        System.out.println("Favorite Movie: Avengers");
    }

    public static void main(String[] args) {
        printFavorite();
    }
}

Add a comment
Know the answer?
Add Answer to:
Let's create a void method and call it from main. Here is what to do. Write...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a void method and call it from main. Here is what to do. Write a...

    Create a void method and call it from main. Here is what to do. Write a void method that does not take any parameters called printFavorite. It should print your name and a favorite (subject, book, movie, etc) of yours. Call the method from main. JAVA

  • In Java: Let's create a method that has parameters. Write a method, called returnHours that returns...

    In Java: Let's create a method that has parameters. Write a method, called returnHours that returns a string. Make the string from a string representing your name and a number representing the hours you spend sleeping, both are values that you pass in from the main. Create the variables to pass into the method call in main. Call the method and print the return value in main. Run and test it.

  • Now create the Book class that inherits from Product. Don't forget that each class must go...

    Now create the Book class that inherits from Product. Don't forget that each class must go in a file with a matching name, so put the Book class in Book.java. In the main method create a new Book object. Use setters to set the author, title and number Pages. Use the getters to print information about the book. Product Felda stock Number price Tethods getto accettera.. Book Food Fields title Pages Hethods etters and setters Fields expiration Year expiration Day...

  • Purpose: To learn how to create and use stand-alone class programs (classes withouta main method)...

    LE 7.2 Purpose: To learn how to create and use stand-alone class programs (classes withouta main method). When you take code out of the application class and put it in a class of its own, you make it reusable Prep Work: Chapter 7 Figure 7.6 shows you how an application class uses the services of a Java class in Figure 7.5. Although the code for LE 7.2 is different than the code in these figures, the concept is the same....

  • create a new Java application called "CheckString" (without the quotation marks) according to the following guidelines....

    create a new Java application called "CheckString" (without the quotation marks) according to the following guidelines. ** Each method below, including main, should handle (catch) any Exceptions that are thrown. ** ** If an Exception is thrown and caught, print the Exception's message to the command line. ** Write a complete Java method called checkWord that takes a String parameter called word, returns nothing, and is declared to throw an Exception of type Exception. In the method, check if the...

  • Project Objectives: To develop ability to write void and value returning methods and to call them...

    Project Objectives: To develop ability to write void and value returning methods and to call them -- Introduction: Methods are commonly used to break a problem down into small manageable pieces. A large task can be broken down into smaller tasks (methods) that contain the details of how to complete that small task. The larger problem is then solved by implementing the smaller tasks (calling the methods) in the correct order. This also allows for efficiencies, since the method can...

  • Java 1. Create an application named NumbersDemo whose main() method holds two integer variables. Assign values...

    Java 1. Create an application named NumbersDemo whose main() method holds two integer variables. Assign values to the variables. In turn, pass each value to methods named displayTwiceTheNumber(), displayNumberPlusFive(), and displayNumberSquared(). Create each method to perform the task its name implies. 2. Modify the NumbersDemo class to accept the values of the two integers from a user at the keyboard. This is the base code given: public class NumbersDemo { public static void main (String args[]) { // Write your...

  • Part 1- Method practice Create a main method. In there, make an array of 100 random...

    Part 1- Method practice Create a main method. In there, make an array of 100 random integers(numbers between 0 and 1000). Create a method to find average of the array. Pass the array and return the number(double) that is the average In the main method, call the method created in Step 2. Print out the average Create a method to find the min value of the array. Pass the array and return the int that is the smallest.(pass the value...

  • Create a program named IntegerFacts whose Main() method declares an array of 10 integers. Call a...

    Create a program named IntegerFacts whose Main() method declares an array of 10 integers. Call a method named FillArray to interactively fill the array with any number of values up to 10 or until a sentinel value (999) is entered. If an entry is not an integer, reprompt the user. Call a second method named Statistics that accepts out parameters for the highest value in the array, lowest value in the array, sum of the values in the array, and...

  • java Create a void method that, when called, prints your name and student number to the...

    java Create a void method that, when called, prints your name and student number to the screen. This method need not accept any arguments – Just print your info.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT