Menu
Topics Index
...
`

Switch expression acceptable type


If you need explanation Read this topic

If you need Answer Take test on this topic

Switch expression acceptable type
Which of the following two types are acceptable as expressions for the switch statement? The expression in the below example is expr.
switch (expr)
{
    default:  
        System.out.println("Hello");
}
1. byte 2. long 3. char 4. float 5. double 6. boolean

A. 1 and 3
B. 2 and 4
C. 3 and 5
D. 4 and 6
Topic: switch Statement In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

ANS IS A

--A switch works with the byte, short, char, and int primitive data types.

--  In Java SE 7 and later, you can use a String object in the switch statement's expression.

--It is selective statement which is used to select case based on expression in it.expression can be of any of above mentioned primitive data type.

Posted by Mânïshå Mùlchåndânï    2014-12-24 10:12:54


a

Posted by Shubham Bansal    2014-12-24 15:58:16


a

Posted by Shubham Bansal    2014-12-24 15:59:04


This dose is now closed and the winners are Sai Ram,  for 'First Correct Comment', Sai Ram, Mânïshå Mùlchåndânï,  for 'Best Comment' and Sai Ram for the 'Popular Comment'. The 'lucky liker' is Shubham Bansal. Please login into Merit Campus using facebook, to claim your recharge. Go to http://java.meritcampus.com/earnings to raise the recharge.

Posted by Merit Campus    2014-12-25 05:28:39


© meritcampus 2019

All Rights Reserved.

Open In App