What is the meaning of the return data type void?

Options
- An empty memory space is returned so that the developers can utilize it.
- void returns no data type.
- void is not supported in Java
- None of the above


CORRECT ANSWER : void returns no data type.

Discussion Board
void returns no data type

Void doesn't have any return type as by its name it is empty. It is used in constructor methods as they can never have a return type. void is used when there is no return type that needs to be mentioned. This method can be used anywhere with any other method and anywhere in the program.

For Example:

The method displayData() does not have a return type as shown by the use of the void keyword.

public class Data {

private String title;
private String author;
private String publisher;

public Data(String title, String author, String publisher)
{
this.title = title;
this.author = author;
this.publisher = publisher;
}

public void displayData()
{
System.out.println("Title: " + title);
System.out.println("Author: " + author);
System.out.println("Publisher: " + publisher);
}
}

Rohit Sharma 07-28-2014 12:18 AM

'void' keyword

When 'void' keyword is used as return type, it specifies that it has no return type

'void' keyword 07-6-2013 01:23 AM

void keyword

The void keyword is means a method won't return any objects.

void keyword 07-6-2013 01:19 AM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement