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
What is the purpose of an interface?
What does string intern() method do?
1.IN CASE OF DYNAMIC METHOD DISPATCH WHY WE USE REFERENCE VARIABLE,WE CAN USE THE DIFFERENT DEFINED OBJECT DIRECTLY TO ACCESS THE DATA MEMBER AND MEMBER FUNCTION OF THAT RESPECTIVE CLASS?WHAT IS THE MAIN FUNCTION OF "REFERENCE VARIABLE" HERE?
How to invoke external process in java.
What is immutable class in java?
what happens when a thread cannot acquire a lock on an object? : Java thread
Why does my function print none?
What is the synonym of procedure?
How to sort a collection of custom Objects in Java?
What is the collections api in java programming?
In multi-threading how can we ensure that a resource isn't used by multiple threads simultaneously?
What is the difference between final, finally and finalize() in java?
Explain notify() method of object class ?
why not override thread to make a runnable? : Java thread
What is a boolean structure?