1.create a class called Guna
2.have main method in it
3.create object Guna
4.call method pen.write(); method
5.outer main method write method definition
- print -- writing in pink colour
public class Guna {
public static void main(String[] args) {
// TODO Auto-generated method stub
Guna pen = new Guna();
pen.write();
}
public void write ()
{
System.out.println("writing in pink colour");
}
}
out put-- writing in pink colour
after create another class called Harish
- have a main method in it
- create object Guna
- method calling pen.write();
- print out put --(writing in pink colour)
package terminaltask;
public class Harish extends Guna {
public static void main(String[] args) {
// TODO Auto-generated method stub
Guna pen = new Guna();
pen.write();
}
}
out put -writing in pink colour
Top comments (0)