Menu
Question Index
...

What will be the output of the following program?

class StudentPass1
{
    public static void main(String s[])
    {
        int marks = 50;

        if( marks >= 70 )
            System.out.println("Distinction");
        else if( marks >= 35 )
            System.out.println("Pass");
        else
            System.out.println("Fail");
        
    }
}

class StudentPass2
{
    public static void main(String s[])
    {
        int marks = 50;

        if( marks >= 70 )
            System.out.println("Distinction");

        if( marks < 70 && marks >= 35 )
            System.out.println("Pass");

        if( marks < 35 )
            System.out.println("Fail");
        
    }
}


Both StudentPass1 and StudentPass2 are same
Both StudentPass1 and StudentPass2 are same and StudentPass2 is faster than StudentPass1
StudentPass1 does not work when marks is initialized to 35
StudentPass1 and StudentPass2 are different

Doubts

Problems

Topic: if else if ladder In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App