Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Father {
- public String x;
- public Father() {
- this.init();
- System.out.println(this);
- System.out.println(this.x);
- }
- protected void init() {
- x = "Father";
- }
- @Override
- public String toString() {
- return "I'm Father";
- }
- void ParentclassMethod(){
- System.out.println("Parent Class");
- }
- }
- public class Son extends Father {
- public String x;
- @Override
- protected void init() {
- System.out.println("Init Called");
- x = "Son";
- }
- @Override
- public String toString() {
- return "I'm Son";
- }
- @Override
- void ParentclassMethod(){
- super.ParentclassMethod();
- System.out.println("Child Class");
- }
- }
- public class MainCLass{
- public static void main(String[] args){
- Son ob = new Son();
- }
Add Comment
Please, Sign In to add comment