This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes TypeSafety 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 "TypeSafety" Watch "TypeSafety" New topic
Author

TypeSafety

Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 423
Hi, This is from Whizlabs..Code, question and my assumptions are given below. Please advice.


OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9400
    
  20

How will this line compile? List is an interface, there is no new keyword and its missing brackets at the end.

For answer 1 and 2 I agree with you.
You can never instantiate a wildcard type, this is why this line doesn't compile.
The 2nd line doesn't compile as aa might not have been initialized. Otherwise it compiles fine which makes answer 3 correct...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 423
Hi Ankit, assignment means, option2 at Line 42 is assigning at Line 26 "list" reference variable (or) reference variable "aa" at line 54 is assigning to bb (or) both ?
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9400
    
  20

Technically when you pass some variables in a method call, its not assignment. But most of the rules that apply to assignment will apply to it. So in this case, rules of generics apply to both line 54 and 42...
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: TypeSafety
 
It's not a secret anymore!