raghuram vadlamani

Greenhorn
+ Follow
since Feb 17, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by raghuram vadlamani

The following question is from the Khalid A.Mughal latest Mock Exam engine http://www.ii.uib.no/~khalid/pgjc3e/engine.html



I think
A is correct as the current directory is not specified in the class path.
B is wrong according to the above
C is wrong as top or top/sub is not beneath the proj directory
D is correct according to above
E is wrong as there is no directory top beneath proj

But the question says that three options are correct , please correct me if i am wrong.
well it a recurssion creating a stack overflow as subclass construtctor calls the superclass constructor .
Hai Kushtwar,

Arrays.sort uses Modified MergeSort algorithm for sorting and API says that it does it in natural ordering of the element and ordering means it has to make some sense rather than random arrangement and the API specifys that it arranges it in ascending order so based on this best way to understand it is using bubble sort as it is the simplest sorting algorithm useful for small list

{person[0],person[1],person[2]} well with natural ordering i.e least will be first so

person[0].compareTo(person[1]) which returns 1 think like >0,0,<0 rather than 1 , 0, -1 as you will get the same output if you return 1,11,11121.... any postive number greater than 0(ofcourse has to be compatible with int )

so person[0] is greater than person[1] now according to bubble sort swap them

then you will have
{person[1],person[0],person[2]}

now person[0].compareTo(person[2]) which is also positive so person[0] is greatest of three so now list will be {person[1],person[2],person[0]}

now person[1].compareTo(person[2]) and person[1] is greater than person[2] so the least is person[2] and obviously the list will be
{person[2],person[1],person[0]}

now using the same least will be first principle if negative number is returned from compareTo then person[0] will be the least then successive comparasion will be same and thus no effect it is the same with 0

I hope you understood
what Ruben said is correct but you are creating object of the serializable class from which you are invoking the overloaded superclass constructor with super(x) but during deserialization it will get the serialized object but this one depends on the superclass "JVM will invoke Superclass constructer i.e no args one "
well compareTo of comparable interface returns int as you know in that -1 is if the passed object is greater than the invoking object meaningfully(this one depends on your parameter), in the above specified one i think you want to sort based on age .Wrapper classes and String has already implemented Comparable based on natural ordering so if you change the age into Integer and return type of getAge as Integer then person[0].getAge().compareTo(person[1].getAge) will give you -1 as 20 is < 30 so for descending order just interchange the above ,

hope that you understood