This type of method does not return a value.
- a. null
- b. void
- c. empty
- d. anonymous
The method which does not return a value is called as “void()”.
Hence, the correct answer is option “B”.
Explanation of Solution
Methods:
A collection of statements which together perform an operation is called as methods.
- The main advantage of using method is reusability of code and it reduces the size of the program, because a method can be called for multiple times in the program.
void() method:
The method void executes a set of statements with no return value.
Explanation for incorrect options:
a. null:
The keyword null is used to declare the null data type
Hence, the option “A” is wrong.
c. Empty:
Empty is used to represent a string which has blank value in it.
Hence, the option “C” is wrong.
d. Anonymous:
There is no method called as “anonymous” in Java, but the nameless object in java is termed as anonymous object.
Hence, the option “D” is wrong.
Want to see more full solutions like this?
Chapter 5 Solutions
STARTING OUT W/JAVA PLUS ACCESS >IP<
Additional Engineering Textbook Solutions
Database Concepts (7th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Starting out with Visual C# (4th Edition)
- Create a method that takes a value and indicate whether it is positive or negative by a return aBoolean value.Declared as: boolean isPositive (float a)arrow_forwardCreate a method that takes a value and tell whether it is null or not.Declared as: boolean isZero (float a)arrow_forwardA method CAN be invoked using a variable that is initialized to null. True O Falsearrow_forward
- What is the return type of a method that does not return any value?arrow_forwardPrime Numbers A prime number is a number that can be evenly divided by only itself and 1. For example, the number 5 is prime because it can be evenly divided by only 1 and 5. The number 6, however, is not prime because it can be evenly divided by 1, 2, 3, and 6. Write a Boolean method named IsPrime that takes an integer as an argument and returns true if the argument is a prime number or false otherwise. Use the method in an application that lets the user enter a number and then displays a message indicating whether the number is prime.arrow_forwardFree Response Question: 28. Write a method that will return true if a randomly generated number between 1 and 10 is less than or equal to 4. public static boolean FortyPercentOrLess() { }arrow_forward
- Retail StoreSuppose you have been consulted by a retail shop around your area to build a simple calculator. The calculator must be able to perform arithmetic operations (+, -, *, /) on integers. The program receives an expression from the user. The expression is structured as follows: integer input followed by an operator and another integer input from user prior to displaying the final result. Write a Java application that can perform the above expression. Create a method that takes two parameters and performs an arithmetic operation on the passed values. Your final output should consist of the expression and the result.arrow_forwardc# uppose there is a method called Current Deposit is your project class. The method header is as below: public static decimal Current Deposit( in years , decimal future, double rate) This method will return the current amount of money in an account if you pass the future amount, the annual interest rate, and years number. Write one statement to declare a decimal variable myMoney, call the method with the future amount $50,000.00, interest rate 8%, and 15 years, and assign the returned value to myMoney.arrow_forwardA program contains the following value-returning method: private int Square(int value) { return value * value; } Write a statement that passes the value 10 as an argument to this method and assigns its return value to the variable result.arrow_forward
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning