Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Artist;
- public class Country {
- private String artist = "Garth Brooks";
- public String setArtist() {
- return artist;
- }
- void does(){
- System.out.println("Plays Country Music" + " he is 57 years old");
- }
- }
- =======================================================================================================================================
- package Artist;
- public class GarthBrooks extends Country{
- public static void main(String args[]){
- Country obj = new Country();
- /* Note: using public setter method
- * to access the private members of parent class
- */
- System.out.println(obj.setArtist());
- obj.does();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment