This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package scenario1; | |
| public class Trainer { | |
| String dept="java"; | |
| String institute="payilagam"; | |
| private int salary=10000; | |
| public Trainer(String dept,String institute) | |
| { | |
| System.out.println(dept); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package scenario1; | |
| public class SQLTrainer extends Trainer { | |
| public SQLTrainer() | |
| { | |
| super("cse","payilagam"); | |
| this.dept="cse"; | |
| this.institute="payilagam"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface Actor { | |
| public boolean makeupRequired = true; | |
| public String address="chennai"; | |
| public void act(); | |
| public void dance(); | |
| public void sing(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ActorSivakumar implements Actor { | |
| public ActorSivakumar(int amount, String brand) | |
| { | |
| System.out.println(amount + brand); | |
| } | |
| public ActorSivakumar() | |
| { | |
| System.out.println("Zero argument constructor for ac"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Samsung extends FactoryDemo { | |
| static int price = 5000; | |
| public static void main(String [] args) | |
| { | |
| Samsung sam = new Samsung(); | |
| sam.browse(); //browse method is calling abstract sub class method and abstract class constructor | |
| System.out.println(sam.price); //5000 is print | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class FactoryDemo extends SmartPhone { | |
| boolean originalPiece=false; | |
| static int price = 0; | |
| public abstract void verifyFingerPrint(); | |
| public abstract void providePattern(); | |
| public void browse() | |
| { | |
| System.out.println("Factory Demo browsing"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class SmartPhone { | |
| public SmartPhone() | |
| { | |
| System.out.println("Smartphone under development"); | |
| } | |
| public abstract int call(int seconds); | |
| public abstract void sendMessage(); | |
| public abstract void receivecall(); | |
| public void browse() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class India { | |
| static String capital = "New Delhi"; | |
| public India(String primeMinister) | |
| { | |
| System.out.println("our Prime Minister is"+ primeMinister); | |
| } | |
| public abstract void speaklanguage(); | |
| public abstract void eat(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class SouthIndia extends India { | |
| public SouthIndia() | |
| { | |
| super("Modi"); | |
| } | |
| public void cultivate() | |
| { | |
| System.out.println("Rice and Wheat cultivation"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class TamilNadu extends SouthIndia { | |
| static String capital = "Chennai"; | |
| public static void main(String [] args) | |
| { | |
| SouthIndia si = new TamilNadu(); | |
| si.speaklanguage(); | |
| si.eat(); //Using si object we can access parent abstract methods | |
| si.dress(); //sub abstract methods but if that method is override child class is get output | |
| si.cultivate(); |