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 is the purpose class.forname method?

560


How to create a custom exception?

574


What is callablestatement? How you can call stored procedure to pass in parameter?

542


What is arguments in java?

523


What is field name?

587






How do you check if an arraylist is not empty?

578


What are 3 data types?

548


How many types of interfaces are there?

578


What do you mean by JVM?

589


What is a file pointer?

516


What do you mean by synchronized non access modifier?

565


What is the maximum size of arraylist in java?

498


What is a numeric string?

564


what is ststic with example

1595


How would you convert bytes to string?

563