Amir Ashfaq

Greenhorn
+ Follow
since Feb 25, 2011
Amir likes ...
Mac Mac OS X
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
3
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Amir Ashfaq

80%... but was OK... as preparation was not too good.. HAPPY
12 years ago
Having problem in registering at CertManager


"Please correct the following:
We could not find a user meeting the specified criteria. Please review the criteria and try again."


At Prometric, my candidate History shows that my Exam Status is passed.

Just like to know after how many days i can register at CertManager.

12 years ago
I have passed SCJP yesterday,,,, and as from August Oracle policy is going to change(compulsory course required ..or), as i heard , so was thinking for taking SCWCD exam before that date, is it possible to make it, and what study material is recommended. and what exactly will be different after August.

Please guide me
i have passed SCJP today,,, ;))
12 years ago
@Krish Khan..

both constant and function dostuff are static thats OK ,,,and reason why will not compile here is because of there assess level.. default is package level access... has nothing to do with static
ok....

new Dozens() creates object of type Dozen, but you need to look in the Dozen Object... it has class variable "dz", which is integer type array. so when one Dozen object is created then one array "dz" is also created as its properly initialized. right?

So when array is created, on heap one Object of type array is created. That object have references to the indexes capable of storing array elements(in this case INTs).


So thats why 2 objects on heap...one Dozens and one Array,

First of all , when object is created???

int a[]; // just a reference type variable. "a" .. which can point to an array. SO no object is created until array is initialized...

like when you write

int a[] = new int[3]; or int a[] = new int[] {1,2,3};
then one array type OBJECT is created.... that object will have 3 indexes capably of storing int type variable each.


so Question 1: there you have one reference variable of type int array, not object. and one "a" reference variable actually pointing to an Object of type Dozens. SO here we have only 1 Object.


Question 2: when you use new keyword to create String Object, the object actually is on heap and the valse "MyName" is stored on pool (as far as i know about it....).

and same for one object of type Dozens... so here we have 2 objects (string, Dozens)
Ok i will first try to explain how many Objects are created...

As execution starts from MAIN....

line 05: One Object of type "Array" is Created.
line 06: Two Objects are created.. ONE: of type Dozen .. TWO: array type referenced by"dz".
line 07: Same 2 Objects (Dozen , Array ) .


/// so total 5 objects are created.

line 08: array's second index will point to same object as "d".
line 09: d is null but array's secound index is still pointing to that object.
line 10: now array's secound index is null...so that object of type Dozen and one array object referenced by local "dz" variable, both are eligible for garbage collection.


feel free to ask again if still have any issue...
Just to summarize in few line.. please agree if its right.

<? super/extends Class> only concerns about the list that can be passed to the method.

and when add(new XX), this XX should qualify "IS A" relation to Class.
OK Thanks for the replies .. So "<? extends Animal> will alow a List of Animal and its Childs" and "<? super Animal> allow upper hierarchy" but we can only add Animal type to that List.




SOME ONE PLEASE REPLY...



As i understand from the "<? super Dog>", list of elements of Dog or any thing above the inheritance tree,,, so i passed Animal List.

Animal can hold Dog... so Line 1 OK...
Animal can hold Animal...and list of animals is passed legally according to "<? super Dog>",

then... why on line 2 ,...cast is needed...and why is cast is provided then exception at RUNTIME



Your question has its answer.. as 12 is assigned within the code and you are sure about the value of "cust" after the execution of that line , so no need for assert "cust>=20".

As Assertion means your assumption, so why you will assume that the value will be >= 20, as you yourself has assigned it 12.


hope you understand...