Question

Java Programming. Define a void method named hello that takes a single boolean parameter. The method...

Java Programming.

Define a void method named hello that takes a single
boolean parameter. The method should print “Hello” if its parameter is true;
otherwise, it should print “Goodbye”

0 0
Add a comment Improve this question Transcribed image text
Answer #1
public void hello(boolean f){
  if(f){
    System.out.println("Hello");
  }
  else{
    System.out.println("Goodbye");
  }
}
Add a comment
Know the answer?
Add Answer to:
Java Programming. Define a void method named hello that takes a single boolean parameter. The method...
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
  • Java two dimensional arrays Create a method named curiousNumber that takes an integer named num as...

    Java two dimensional arrays Create a method named curiousNumber that takes an integer named num as a parameter and returns a boolean. You can assume the num will be a positive integer. The curiousNumber method should determine whether num is a curious number. A curious number is a number that is equal to the sum of the factorial of each of its digits. For example, 145 is a curious number because 145 = 1! + 4! + 5!. sample: boolean...

  • java programming. One. Write a method public boolean hasOnlyoddDigits(int n) that returns true if its parameter...

    java programming. One. Write a method public boolean hasOnlyoddDigits(int n) that returns true if its parameter n contains only odd digits (1, 3, 5, 7, or 9), and returns false otherwise. Zero is counted as an even digit whenever it appears inside the number. Remember that for a positive integer n, the expression (n % 10) gives its last digit, and the expression (n / 10) gives its other digits. Correct answer true false false false 357199 7540573 97531000

  • JAVA 1.Write a static method named getMaxEven(numbers) which takes an array of positive integers as a...

    JAVA 1.Write a static method named getMaxEven(numbers) which takes an array of positive integers as a parameter. This method calculates and returns the largest even number in the list. If there are no even numbers in the array, the method should return 0. You can assume that the array is not empty. For example: Test Result int[] values = {1, 4, 5, 9}; System.out.println(getMaxEven(values)); 4 System.out.println(getMaxEven(new int[]{1, 3, 5, 9})); 0 public static int --------------------------------------------------------------------------------- 2. Write a static method...

  • Intro to Java Programming Write a method named isDivisible that takes two integers, n and m,...

    Intro to Java Programming Write a method named isDivisible that takes two integers, n and m, and that returns true if n is divisible by m, and false otherwise. Include your isDivisible() function as a method in Functions. In the main static method, demonstrate isDivisible() works by testing that it returns both possibilities correctly for a few different pairs of numbers. Include comments before your test code describing what's going on. The definition of divisibility is "One whole number is...

  • in java Write a class named Palindrome.java and Write a method isPalindrome that takes an IntQueue...

    in java Write a class named Palindrome.java and Write a method isPalindrome that takes an IntQueue as a parameter and that returns whether or not the numbers in the queue represent a palindrome (true if they do, false otherwise). A sequence of numbers is considered a palindrome if it is the same in reverse order. For example, suppose a Queue called q stores this sequence of values: front [3, 8, 17, 9, 17, 8, 3] back Then the following call:...

  • Write a Java code to define an interface called FrugalList which contains a method named pushBack....

    Write a Java code to define an interface called FrugalList which contains a method named pushBack. The method pushBack takes an Object type argument and returns a boolean value.

  • In Python 3 Write a LinkedList method named contains, that takes a value as a parameter...

    In Python 3 Write a LinkedList method named contains, that takes a value as a parameter and returns True if that value is in the linked list, but returns False otherwise.

  • java coding question: Write a complete program that contains a method named repeat that takes a...

    java coding question: Write a complete program that contains a method named repeat that takes a String as a parameter and returns nothing The method will print (use System.out.println) the input string 5 times. The main method will call the method repeat with the value "Java".

  • Write a method in java named isValidEmail that takes a string as input parameter, and returns...

    Write a method in java named isValidEmail that takes a string as input parameter, and returns true if that string represents a valid email address, or false otherwise. An email address is considered valid if it follows this format “user123@domain.ext”, where:  user123 represents a sequence of word characters (i.e., letters, digits, or underscore) whose length is between 1 and 10 (inclusive), but the first character must be a letter  domain represents a sequence of alphanumeric characters (i.e., letters...

  • Write a method named avgLength which takes an array of Strings as an input parameter and...

    Write a method named avgLength which takes an array of Strings as an input parameter and returns a double. The method should calculate and return the average length of all the strings in the array (in java langauge)

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