public class hello_world {
public void sample(){
System.out.println("Hello World");
}
};
/*Now I can access this method using an Instance of it in my Main Class or by inheriting it.*
Public Class main{
public static void main(String args[]){
hello_world sam = new hello_world();
sam.sample();
};
}
/*Class using inheritance
Public Class main extends hello_world {
public static void main(String args[]){
sample();
};
Using inheritance and instance I can achieve the same result.
Can someone let me know as to whats is the benefit of using and Instance and benefit of using inheritance.