Question

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.

  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.

JAVA

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

    public static void printFavorite() {
        System.out.println("Your Name");
        System.out.println("Favorite movie is Avengers Infinity War");
    }

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

Add a comment
Know the answer?
Add Answer to:
Create a void method and call it from main. Here is what to do. Write a...
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
  • 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. 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. Run and test it. For IDEs: Submit your .java file and a screenshot of the output of your code.

  • 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.

  • 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.

  • 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 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...

  • Please write this in java Write one static method to print each character in the output....

    Please write this in java Write one static method to print each character in the output. There should be methods to print: H, E, L, O, (comma), W, R, D and (exclamation point). The method to print H should be called printH() and the method to print the comma should be called printComma(). Make sure to separate characters with a new line in the method (except the comma) as shown on right. Write a method called printHelloWorld() to call the...

  • I've been assigned to create a new Java application called "CheckString" (without the quotation marks) according...

    I've been assigned to 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...

  • 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...

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
ADVERTISEMENT