Wednesday, March 3, 2010

OOP test ...today

salam...this is oop



class ScopingExample {
int i=1;
public void firstMethod() {
int i=4, j=5;
this.i = i + j;
secondMethod(7);
System.out.println("In first method i = " + i);
}

void secondMethod(int i) {
int j =8;
this.i = i + j;
System.out.println("In second method i = " + i);
}
int getI() {
return i;
}
}

public class TestScoping {
public static void main(String[] args) {
ScopingExample scope=new ScopingExample();
scope.firstMethod();
System.out.println("In main method i = " +
scope.getI() );
}
}
Share:

2 comments:

  1. salam..

    bagus, sampai update blog pun gune programming language..all da best=)

    ReplyDelete
  2. demam programming
    sye suke programming tapi xscore pun

    ReplyDelete