Deepa aroon wrote:Hi,
Am Deepa. I am very new to this forum. I am giving my ocpjp exam on august 1... so can anyone tell me whether serialization topic is there for exam or not?
Tere Luna wrote:Thank you Boris
![]()
Your explanation is very clear! Now I'm testing by using only primitive not wrapper, like in the code below
And I get the "Type mismatch: cannot convert from int to short" compiler error in line 2. I thought this could be implicit casting :S
Thanks for your help !
Tere
Rohit Sidana wrote:Hi...everyone....Today i was reading my book where i got one statement that " Static methods can't be overridden but can be redefined."
Can anyone please explain me this statement that what is the difference between redefine a code and override the code?
and the output of this code is :
a a a
Ash Gill wrote:cheers Boris, got it. very informative reply, never knew about the iterator thing in PQ. thanks a lot.
ai dan wrote:How realistic is the oracle sample exam compared to the real thing?
sid noob wrote:Boris, thanks for the beautiful and lucid explanation. You actually cleared some earlier concepts too that was foggy. Great explanation, i understood multi-dimensional arrays as well as how the init block actually works and not to forget the post decrement operator [the chapter am studying].
![]()
sid noob wrote:class Twisty {
{ index = 1; }
int index;
public static void main(String[] args) {
new Twisty().go();
}
void go() {
int [][] dd = {{9,8,7}, {6,5,4}, {3,2,1,0}};
System.out.println(dd[index++][index++]);
}
}
Please help me to understand this program, i am unable to understand as to how the output shows as 4 without any errors on running the program.
Regards,
Sid.
Ash Gill wrote:Hi Boris, thanks a lot for the reply. can you please explain a bit more on:
remember there is no order in the PQ
ques: priority queues are sorted and the order representes priorities of the elements. then arn't PQ ordered?
Can you get two elements from a PriorityQueue without removing any? The answer is no. "Peek", "poll", "remove" and all other methods in the PriorityQueue API work on the element AT THE HEAD of the queue. This means you cant get to the second element (whatever that is, remember there is no order in the PQ) without removing the first one.
LinkedList has indexed access, meaning you can get a specific element at a specific index.
yes, i follow the above points but we can always traverse a PQ, without removing any element, using an Iterator and the Iterator can be used in the same way to traverse a LinkedList.
for eg:
ques: i understand that this is not same as getting to a particular element in a linkedlist using get(int index), but it is still a non-destructive traversal, isnt it?. please correct me.
thanks and regards
Ash Gill wrote:hello everyone, can anyone please clarify this:
then does Harry also implement Tommable indirectly?
thanks and regards
Ash Gill wrote:Hello guys, in one of the questions in K & B, i found this
It’s programmatically easier to perform a non-destructive traversal of a PriorityQueue
than a LinkedList. correct or incorrect?
and the answer was: is incorrect because the PriorityQueue class itself provides
no non-destructive traversal methods.
what do they mean by non-destructive traversal? if they mean traversing without removing objects then PriorityQueue does inherit peek() method which returns the highest priority element.
is the opposite of the statement correct i.e. "It’s programmatically easier to perform a non-destructive traversal of a linked list than a PriorityQueue"
many thanks and regards
Tere Luna wrote:Hi All
![]()
I'm a little confused about implicit and explicit casting in Java. I'm preparing for OCPJP, but I have the below code, and I wonder why when you perform an arithmetic operation using literals like 3/2, that can be assigned to a short type attribute, but if you try to perform the same operation but using a variable like short1/4, you get a compiler error. Also the same in the line 5, where you want to assign a byte to a short, I would assume it would compile since byte is lower precision than short, and I would think it would perform an implicit casting
1. Short short1 = 3;
2. Byte byte1 = 4;
3. short1 = 3/2;
4. Short short2 = short1 / 4;
5. short1 = byte1;
Thanks for your help![]()
Tere
ai dan wrote:Has Serialization not been removed?
Gursewak Singh wrote:i have a code:
subClass obj=new superClass();
obj.eat();
Here eat() method is overridden in the sub class.
as we know that in case of method overriding Object type(not reference type determine) ,determine which overridden method is used at run time.so in this case this code should work according to statement.
But this show compilation error for incompatible type.
so i want to know ,why?
Gordon Keenan wrote:Hi,
I am sitting the OCPJP exam this week and I just came across this question in Oracle's list of sample questions for the exam.
If, on line 7, t is successfully serialized and then deserialized, what is the result?
The answer they give is "0 7 0" as correct, stating correctly that static or transient variables are not serialized.
However x1 should still be 7, the same as it is set two lines above as it is static.
So the answer should be 7 7 0.
This does not inspire me with confidence for the exam![]()
The question can be found on the link below, labeled objective 3.3
// You might need to select your region
http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=303&p_certName=SQ1Z0-851
Sam Hazim wrote:Since the move to Oracle the exam has been shortened to 2.5 hours (down from 3) and raised the passing score somewhat. This concerns me slightly as 2.5 mins per question seems a lot tighter than I'd like (whilst I think I could complete the exam I don't think I'd have much time spare).
Seems like it's harder than ever to pass the exam, how does everyone feel about that?