Day 13: Abstract Classes | 30 Days of Coding | HackerRank | Java Language

**Before watching this make sure that you’ve tried enough**
Language: Java 7

// Declare your class here. Do not use the 'public' access modifier.
class MyBook extends Book 

    // Declare the price instance variable
    private int prc;
    *   Class Constructor
    *   @param title The book's title.
    *   @param author The book's author.
    *   @param price The book's price.
    // Write your constructor here
    MyBook(String ttl, String athr, int prc)
        super(ttl, athr);
        this.prc = prc;
    *   Method Name: display
    *   Print the title, author, and price in the specified format.
    // Write your method here
    void display(){
        System.out.println("Title: "+title);
        System.out.println("Author: "+author);
        System.out.println("Price: "+this.prc);
// End class


If this solution helped you, please share this with your friends.
And if you have anything to say, let me know in the comment section.
More solutions are coming so Like our Facebook page and Subscribe to our YouTube channel to stay connected.

Leave a Comment