Menu
Question Index
...

Compare the following programs FindWinner1 and FindWinner2.

class FindWinner1
{
    public static void main(String s[])
    {
        int india_score = 300, pakistan_score = 290;
        
        if( india_score > pakistan_score )
            System.out.println("India Wins");
        else
            System.out.println("Pakistan Wins");
    }
}

class FindWinner2
{
    public static void main(String s[])
    {
        int india_score = 300;
        int pakistan_score = 290;
        
        System.out.println( india_score > pakistan_score ? "India Wins" : "Pakistan Wins");
    }
}


Both FindWinner1 and FindWinner2 are same
FindWinner1 does not compile
FindWinner2 does not compile
FindWinner1 and FindWinner2 are different

Doubts

Problems

Topic: Java for loops vs Java while loops vs Java do while loops

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App