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 / manikandan

In the line 12 .jus think new Integer(1) will result 1 and
new Integer(2) will result 2 so 1+2=3 which is stored in a i.

so the line 12 can b written as a Integer i=1+3;

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you join strings in java?

532


Which language is java?

552


What is the difference between variable declaration and variable initialization?

514


what is interface in java? Explain

541


What checkbox method allows you to tell if a checkbox is checked?

554






What are synchronized methods ?

627


List down the methods and interfaces of collection class in java.

560


What do you know about the garbage collector in java?

579


What is the major difference between linkedlist and arraylist?

516


What is null in java?

536


Explain public static void main(string args[]).

573


What are constants and how to create constants in java?

564


What if the main() method is declared as private? What happens when the static modifier is removed from the signature of the main() method?

698


What is the public field modifier?

547


What is the maximum size of hashmap in java?

553