Creating Object
Creating object of StackOfmethod class
StackOfmethod ob1=new StackOfmethod();
Overloading Methods
public void method(){
System.out.println("Nothing to print");
}
public void method(String name){
System.out.println("Hello " +name);
}
Constructor
System.out.println("Hello "+name);
System.out.println("Your Age " + Age );
}
*** class name StackOfmethod
Access private variable
private int x=10;
private int y=15;
public void accessPrivateVariable(){
int res=0;
res =x+y;
System.out.println(res);
}
** variable out side any method are called instance variable
No comments:
Post a Comment