question 23

Posted Thursday, September 03, 2009 by SacrosanctBlood in

Pretty simple question. What would happen if you try to execute the
below program?

public Class States{

private String state;

     public States(String state){

           this.state = state;

     }

public String getState(){

     return state;

}

public void setState(String state){

     this.state = state;

}

public void clearState(){

     this = null;

}

public static void main(String args[]){

     States s = new States(“Active”);

     s.clearState();

}

}



1 comment(s) to... “question 23”

1 comments:

SacrosanctBlood said...

The program will not compile, as the left hand side (this) is not a
variable.



Post a Comment