[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

JAVA Programming :: Basic Concepts - Discussion

Home > JAVA Programming > Basic Concepts > MCQs Questions Discussion

20 / 64

What will be the output of the below code segement:

public class SwitchTest {
public static void main(String argv[]) {
SwitchTest ms=new SwitchTest();
ms.display();
}
public void display() {
        int k=10;
        switch(k){
            
            default:
            System.out.println("This is the default output");
            break;
            case 10:
            System.out.println("ten");
            break;
            case 20:
            System.out.println("twenty");
            break;
        }
    }
}

Aten

Btwenty

Cten twenty

DNone

Answer: Option (Login/Signup)

Show Explanation

The switch takes the argument or the choice as k, or 10.

Hence, case 10 gets executed, and we get the output as ten.

Asked In :: Virtusa TCS NQT

Post Your Answer Here:     

Reply    
Rate This: +0 -0
    Report


Report Error

Please Login First Click Here