Java Programming - Flow Control - Discussion
Discussion Forum : Flow Control - General Questions (Q.No. 2)
2.
switch(x)
{
default:
System.out.println("Hello");
}
Which two are acceptable types for x?
- byte
- long
- char
- float
- Short
- Long
Answer: Option
Explanation:
Switch statements are based on integer expressions and since both bytes and chars can implicitly be widened to an integer, these can also be used. Also shorts can be used. Short and Long are wrapper classes and reference types can not be used as variables.
Discussion:
16 comments Page 2 of 2.
Anish kumar said:
9 years ago
From 1.5 version all wrapper class is allowed e.g Integer, Short.
From 1.7 version string is also allowed.
From 1.7 version string is also allowed.
Ayush said:
8 years ago
What about unboxing feature of wrapper classes which convert the wrapper class to primitive type?
AJAY said:
1 decade ago
What is the meaning of 1.4v?
Thanks in advance.
Thanks in advance.
Saurabh said:
1 decade ago
About byte data type in java. ?
BrutherJ said:
1 decade ago
What Pearl said?
Suri said:
9 years ago
Correct @Anish.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers