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 a java lambda expression?
Can we clone singleton class in java?
why not override thread to make a runnable? : Java thread
What is final, finally, finalize?
What is the difference between class & object?
This abstract class is correct ? abstract class A { public abstract void Disp(); public abstract void B() { } public absract virtual C() { } }
Describe the term diamond problem.
Why are parameters used in functions?
What are the basic concepts of OOPS in java?
What is java console application?
What is difference between static class and singleton pattern?
Can we make constructors static?
Why stringbuilder is not thread safe?
What is scope of a variable?
How can we use primitive data types as objects?