Asked Dec 5, 2019

What is wrong with the following code? How would you fix it?

public static returnTrue(boolean b){
    if (b){
        return true;
    } else {
        return true;


Expert Answer

Step 1

A Boolean expression is an expression of Java that returns a Boolean value: true or false.

Step 2

Java Boolean returns a Boolean value. If the argument is not null and is a Boolean object representing the same Boolean value as this one, it returns true, otherwise, it returns false.

In this Boolean data, the type is not declared in the program that’s why the user was getting an error after the execution of the program.
There are two functions:

Void: This function does not have a return value. Their syntax is
void func();


Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in


Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A

Q: What is encapsulation?Clarify with help of example?

A: Programming language assumed is c++.Data encapsulation:Normally, encapsulation is defined as wrappin...


Q: using an array write a program that will ask the user to enter a temperature for each day of the wee...

A: The approach and program to find the highest, lowest and the average temperature of a week by using ...


Q: How can I create the following table using printf() method In Java Eclipce.

A: printf() method in java: In java, printf() belongs to the PrintStream class.The printf() method is u...


Q: In Python Define a function writeScores with two parameters. The first should be the name of a file,...

A: Below is the approach and python code:Approach:Define a function “writeScores” having two parameters...


Q: |(1st part) You are going to draw flowers a certain integral locations on a wall in your room. You h...

A: Program Instructions: In main method, call the function draw with length and location array.In funct...


Q: If you wanted to apply an exception for the current subnet, what would you type?

A: Explanation:The user can type the following on linux to apply exception for the current subnet,defau...


Q: How does Amazon Web Services support Netfilx as an information system?

A: The way that AWS support Netflix:Neflix is the leading internet Television (TV) network in the world...


Q: Module/Week 7 ASSIGNMENT (ARRAYS)Use functional decomposition to write a C++ program that asks the u...

A: This C++ program is used to calculate the user's weight according to the planet. To calculate weight...


Q: What are formatted input and output statements?

A: Formatting –The C or C++ language allows a programmer to format an input to process the value for fu...