The output here is
Ozymandias
null
Javin Paul wrote:
are you aware of stack trace ?
Whenever a thread calls a method it put it into its stack and when an Exception get thrown it unwind this stack until Exception get caught or until thread dies. this stack trace is useful to find out where exactly problem lies. just run your program with some other String "Symbiosis" and you will know why need to print stack trace.
please someone tell me if the serialization have been removed from the syllabus or not.......one of my friend told me that it has been removed.....
Develop code that serializes and/or de-serializes objects using the following APIs from java.io: DataInputStream, DataOutputStream, FileInputStream, FileOutputStream, ObjectInputStream, ObjectOutputStream and Serializable.
Meena Ajay wrote:Hi Hennry ,
As given in the answer from K&B,Did you catch the static initializer block given at the end of the code - line 19.?
After the line 4. executes, the value of x is set to 7.Since there is a static initializer block ( given in line number 19.), this would be the next thing to run. So, the value of x would be incremented to 8 after the static initializer block executes.
Now, the code enters the for loop with value of x having 8.After the x++ at line 8. is executed, the value of x becomes 9 and this enters the switch and case 9: would be executed. As per the looping logic, D is the answer"9 10 10 d 13 "
Hope this helps.
And given that line 7 will assign the value 0, 1, or 2 to sw, which are true? (Choose all that apply.)
A. Compilation fails
B. A ClassCastException might be thrown
C. A StackOverflowError might be thrown
D. A NullPointerException might be thrown
E. An IllegalStateException might be thrown
F. The program might hang without ever completing
G. The program will always complete without exception
Answer:
D and F are correct. Because i was not initialized, case 1 will throw an NPE. Case 0 will
initiate an endless loop, not a stack overflow. Case 2's downcast will not cause an exception.
What is the result?
A. 9 10 d
B. 8 9 10 d
C. 9 10 10 d
D. 9 10 10 d 13
E. 8 9 10 10 d 13
F. 8 9 10 9 10 10 d 13
G. Compilation fails
Answer:
D is correct. Did you catch the static initializer block? Remember that switches work on
"fall-thru" logic, and that fall-thru logic also applies to the default case, which is used when
no other case matches.
A, B, C, E, F, and G are incorrect based on the above.
Please tell how D is correct...???