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


Please Help Members By Posting Answers For Below Questions

What does substring mean?

711


What is a buffer in computer?

722


Explain the use of javap tool.

870


What's the purpose of static methods and static variables?

814


What is oop in java?

727


Is class is a data type?

808


what is a green thread? : Java thread

799


Is java free for commercial?

671


Are there structures in java?

742


What is meant by memory leak?

739


Explain reverse a linked list iterative solution in java?

713


Write a program to find maximum and minimum number in array?

769


Explain about instanceof operator in java?

812


Can you create an object of an abstract class?

775


What are the characteristics of java?

742