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
Can you explain inner class.
Can a class be private or protected in java?
Why Java is not pure Object Oriented language?
What are design patterns and please explain?
What do you mean by flow of struts?
Write a program to print the pattern given below
What are java annotations?
What is the difference between object oriented programming language and object based programming language?
What is the default size of set in java?
What is use of functional interface in java 8? Explain
what is method reference in java 8?
Define nashorn in java8.
Explain about main() method in java ?
What is floor in java?
What is the use of default method in interface in java?