• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Understanding few trips/traps of SCJP exam

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 67
Eclipse IDE Fedora Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Rahul Choudhary
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for well written examples Abhilash. That helped
 
Greenhorn
Posts: 15
MS IE Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would say that this line of code would not compile



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



Regards
/Danjel
 
reply
    Bookmark Topic Watch Topic
  • New Topic