Greetings once again everyone
I have reviewed chapter 8 from Kathy's and Bert's book , taking the corresponding
test and there's a question which has got my attention with an issue.
Page 700 , question (answered) 12 , from the book. ( It's the solved questions with explanation page).
Given:
What is the result?
A. Compilation fails
B. button key lint nickel
nickel lint key button
C. nickel button key lint
button key lint nickel
D. nickel button key lint
nickel button key lint
E. nickel button key lint
nickel lint key button
F. An exception is thrown at runtime
Answer:
✓ A is correct, the inner class Sorter must be declared static to be called from the static
method main(). If Sorter had been static, answer E would be correct.
B, C, D, E, and F are incorrect based on the above. (Objectives 1.1, 1.4, 6.5)
Inner class question
------------------------
As it it Sorter inner class, it only can be accessed changing to static compare method . Would it be valid if I want to access method through this way? -> Pockets.Sorter s = Pockets.new Sorter () ; ( or do I get same error cause I am inside static main method? ) .
And the second question regarding sort method of Arrays class:
It says , changing compare method to static in Sorter inner class , answer would be E.
I really have tested in my
IDE different options in order to know how array is sorted but I really can't get it clear enough. How does it work?
!Oh! by the way, what are the differences between "sorted" and "ordered" ?
Thanks in advance.