class Person{
// inatamce variable initialize here
String name="VenKat";
int age=30;
//methods
void talk(){
System.out.println("hello I am "+name);
System.out.println("My age is "+age); }
}
class MainClass{
public static void main(String[]arr){
// create here Person class object
Person p=new Person();
p.name="shashi";
p.age=20;
p.talk(); }
}
That is Output
e:\>javac Person.java
e:>java MainClass
hello I am shashi
My age is 20
0 comments:
Post a Comment