Given:
11. public static void main(String[] args) {
12. Integer i = uew Integer(1) + new Integer(2);
13. switch(i) {
14. case 3: System.out.println(”three”); break;
15. default: System.out.println(”other”); break;
16. }
17. }
‘What is the result?
1 three
2 other
3 An exception is thrown at runtime.
4 Compilation fails because of an error on
line 12.
Answer Posted / nirmal
Ans 4: Compilation fails because of an error on
line 12.
Reason: The operator + is undefined for the argument type
(s) java.lang.Integer, java.lang.Integer Cannot switch on a
value of type Integer. Only int values or enum constants
are permitted.
| Is This Answer Correct ? | 0 Yes | 4 No |
Post New Answer View All Answers
Explain jdk, jre and jvm?
State two differences between C and Java.
Why java doesn’t support multiple inheritances?
What are controls and their different types in awt?
What is JVM and is it platform independent?
How do we access static members in java?
Can an interface have a class?
What is difference between equal and == in java?
What is ternary operator?
What is java command?
Does treeset allow null in java?
Can java program run without jre?
What is connection class in java?
What are functions in java?
What is the base class in java from which all classes are derived?