Menu
Question Index
...

What will be the output of the following program?

class Company
{
    public static void main(String args[])
    {
        Software.NestedIF nif = new Project();
        
        if(nif.isNotNegative(10))
            System.out.println("10 is not negative");

        if(nif.isNotNegative(-12))
            System.out.println("This won't be displayed");
    }
}

class Software
{
    public interface NestedIF
    {
        boolean isNotNegative(int x);
    }
}

class Project implements Software.NestedIF
{
    public boolean isNotNegative(int x)
    {
        return x < 0 ? false : true;
    }
}


10 is not negative
This won't be displayed
10 is not negative
This won't be displayed
Compilation Error
Runtime Error

Doubts

Problems

Topic: Java Interface

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App