Abstract Classes

  • + 0 comments

    Java solution - passes 100% of test cases

    From my HackerRank solutions.

    class MyBook extends Book {
        int price;
        
        MyBook(String title, String author, int price) {
            super(title, author);
            this.price = price;
        }
        
        void display() {
            System.out.println("Title: "  + title);
            System.out.println("Author: " + author);
            System.out.println("Price: "  + price);
        }
    }