Page 1 of 1

About Question enthuware.ocpjp.v7.2.1227 :

Posted: Tue Oct 23, 2012 4:25 am
by D3x!
if str is valid how is obj not valid?

Code: Select all

 final String str = "100"; 
final String obj = "100"; 
public int m3(String a, int b){
         String val = "100";
         Integer iv = 100;
         int i = 100;
         switch(a){
              case  XXXX  : return 1;
          }
         return 0; }

 What can replace XXXX to make the code compile?
"100" and str both are Strings and are compile time constants and are thus valid.

Re: About Question enthuware.ocpjp.v7.2.1227 :

Posted: Tue Oct 23, 2012 6:44 am
by admin
You are right. It should be : final Object obj = "100";
This has now been fixed.

thank you for your feedback!