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
How does linkedhashmap work in java?
Why string is not a wrapper class?
what is interface in java? Explain
Can You Have Virtual Functions In Java?
What is java in detail?
What are peerless components in java programming?
What is the difference between declaration and definition in java?
What is a percentage sign called?
explain autoboxing in java?
Are the imports checked for validity at compile time? Will the code containing an import such as java.lang.abcd compile?
What is the argument in java?
Can we use return in constructor?
Give few difference between constructor and method?
What is meant by local variable and instance variable?
What is the purpose of declaring a variable as final?