java variable inside scope .

public class pk {                               // heiglited word are key word reserved for java use

public static void main(String[] args) {

// TODO Auto-generated method stub

booleangameOver = true ;

int score = 5000;

int levelCompleted = 5;

int bonus = 100;

if (gameOver == true){                 // concept of variable inside code block is called scope

                                              // scope deals with accesbility of variable inside code block

int finalScore = score + (levelCompleted* bonus);

System.out.println(“final score was” + finalScore);


int savedFinalScore= finalScore;   // this line of code give error y becoz variable created                                                      //inside code block

                                              // can not be accesed from outside of code block



Leave a Reply

Your email address will not be published.