Menu
Topics Index
...
`


Exploring java.lang >
Siva Nookala - 06 Oct 2016
The Void class has one field, TYPE, which holds a reference to the Class object for type void.

Void is not a wrapper class.You do not create instances of this class.So the Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the primitive Java type void.
Void
class VoidExample
{
    public static void main(String[] args)
    {
        methodScore(600);
    }
    
    public static void methodScore(int marks)
    {
        if (marks >= 450)
        {
            System.out.println("Distinction");
        }
        else if (marks >= 360)
        {
            System.out.println("First Class");
        }
        else
        {
            System.out.println("Just Pass");
        }
    }
}
OUTPUT

Distinction

DESCRIPTION

Here, in the above example we are considering a void method methodScore. This method is a void method which does not return any value. Call to a void method must be a statement only.

0
Wrong
Score more than 2 points

© meritcampus 2016 - 2017

All Rights Reserved.