my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Understanding few trips/traps of SCJP exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Understanding few trips/traps of SCJP exam" Watch "Understanding few trips/traps of SCJP exam" New topic
Author

Understanding few trips/traps of SCJP exam

Rahul Choudhary
Greenhorn

Joined: Jul 25, 2012
Posts: 22
Hey everyone. I was going through one of the FAQs in SCJP FAQ Page which was What are some potential trips/traps in the SCJP exam?

Two sentences I did not understand and I was hoping someone could explain them.

1. Forward references to variables gives a compiler error.
2. Primitive array types can never be assigned to each other, even though the primitives themselves can be assigned. For example, ArrayofLongPrimitives = ArrayofIntegerPrimitives gives compiler error even though longvar = intvar is perfectly valid.

Thanks.
Abhilash Sharma
Ranch Hand

Joined: Dec 05, 2010
Posts: 67

Rahul Choudhary wrote:Hey everyone. I was going through one of the FAQs in SCJP FAQ Page which was What are some potential trips/traps in the SCJP exam?

Two sentences I did not understand and I was hoping someone could explain them.

1. Forward references to variables gives a compiler error.
2. Primitive array types can never be assigned to each other, even though the primitives themselves can be assigned. For example, ArrayofLongPrimitives = ArrayofIntegerPrimitives gives compiler error even though longvar = intvar is perfectly valid.

Thanks.


1. Forward referencing means that you are trying to use a variable before it's initialization in a class.

}
but in this case


2.Arrays are object in java. So you can assign them to each other if they are of same type.

for example


OCPJP 6 | OCEJWCD 6
Rahul Choudhary
Greenhorn

Joined: Jul 25, 2012
Posts: 22
Thank you for well written examples Abhilash. That helped
Danjel Nyberg
Greenhorn

Joined: Sep 12, 2012
Posts: 15

I would say that this line of code would not compile



however if you put it like this, then it would work



Regards
/Danjel
 
Consider Paul's rocket mass heater.
 
subject: Understanding few trips/traps of SCJP exam
 
Similar Threads
Cleared SCJP 5 with 78%
About potential trips/traps in the SCJP exam in FAQ
SCJP 1.4 tips
Check out our new SCJP FAQ
SCJP FAQ