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.
AJAY said:
1 decade ago
What is the meaning of 1.4v?
Thanks in advance.
Thanks in advance.
NARENDRA said:
10 years ago
1.4 means java 2 platform 1.4 here principle production are J2SDK 1.4, J2SRE 1.4.
Code name is Merlin, released on Feb 6, 2002 editions J2ME, J2SE, J2EE.
Present java 7 version running JDK 1.7.
Code name is Merlin, released on Feb 6, 2002 editions J2ME, J2SE, J2EE.
Present java 7 version running JDK 1.7.
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.
Suri said:
9 years ago
Correct @Anish.
Pratik said:
8 years ago
It also works with enumerated types (discussed in Enum Types), the String class, and a few special classes that wrap certain primitive types: Character, Byte, Short, and Integer.
So, the option 3 is also right.
So, the option 3 is also right.
Ayush said:
8 years ago
What about unboxing feature of wrapper classes which convert the wrapper class to primitive type?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers