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+2;
the answer is 1) three
| Is This Answer Correct ? | 5 Yes | 1 No |
Post New Answer View All Answers
Explain when we should make an instance variable private.
How to display all the prime numbers between 1 and n (n is the number, get the input from user)
What is difference between throw and throws ?
What does it mean that a method or field is “static”?
Given a singly linked list, find the middle of the list in a single traversal without using temporary variable.
What is meant by javabeans?
Tell me a few examples of final classes defined in Java API?
What is the latest java version?
Explain about member inner classes?
What is anagram number?
What is literal example?
What is maximum size of arraylist in java?
Can a class be defined inside an interface?
What does singleton class mean?
What are the main features of java?