HackerRank Day 13 Abstract Classes 30 days of code solution YASH PAL, 31 July 202413 October 2025 HackerRank Day 13 Abstract Classes solution – In this HackerRank Day 13 Abstract Classes 30 days of code problem set, we have two classes Book and Solution. we need to make a new class MyBook that inherited from Book and can print the details.ObjectiveToday, we will extend what we learned yesterday about Inheritance to Abstract Classes. Because this is a very specific object oriented concept, submissions are limited to the few languages that use this construct. Check out the Tutorial tab for learning materials and an instructional video. TaskGiven a Book class and a Solution class, write a MyBook class that does the following:Inherits from BookHas a parameterized constructor taking these 3 parameters:string titlestring authorint priceImplements the Book class’ abstract display() method so it prints these 3 lines:Title:, a space, and then the current instance’s title.Autho:, a space, and then the current instance’s author.Price, a space, and then the current instance’s price.Note: Because these classes are being written in the same file, you must not use an access modifier (e.g.: public) when declaring MyBook or your code will not execute.Input Format You are not responsible for reading any input from stdin. The Solution class creates a Book object and calls the MyBook class constructor (passing it the necessary arguments). It then calls the display method on the Book object.Output FormatThe void display() method should print and label the respective title, author, and price of the MyBook object’s instance (with each value on its own line) like so:Title: $titleAuthor: $authorPrice: $priceNote: The $ is prepended to variable names to indicate they are placeholders for variables.Problem solution in Python 2 programming.#Write MyBook class class MyBook(Book): def __init__(self,title,author,price): Book.__init__(self,title,author) self.price=price def display(self): print "Title: " + self.title print "Author: " + self.author print "Price: " + str(self.price)Problem solution in Python 3 programming.#Write MyBook class class MyBook(Book): def __init__(self,title,author,price): self.title = title self.author = author self.price = price def display(self): print("Title:", title) print("Author:", author) print("Price:",price)Problem solution in java programming.class MyBook extends Book{ int price; MyBook(String title, String author, int price){ super(title, author); this.price = price; } public void display(){ System.out.println( "Title: " + this.title + "n" + "Author: " + this.author + "n" + "Price: " + this.price ); } }Problem solution in c++ programming.//Write MyBook class class MyBook : public Book { private: int price; public: MyBook(string title, string author, int price) : Book(title, author), price(price) { } void display(){ cout << "Title: " << title << endl; cout << "Author: " << author << endl; cout << "Price: " << price << endl; } };Problem solution in Javascript programming.// Declare your class here. class MyBook extends Book{ /** * Class Constructor * * @param title The book's title. * @param author The book's author. * @param price The book's price. **/ // Write your constructor here constructor(title, author, price) { super(title, author); this.price = price; } /** * Method Name: display * * Print the title, author, and price in the specified format. **/ // Write your method here display() { console.log('Title: ' + this.title); console.log('Author: ' + this.author); console.log('Price: ' + this.price); } // End class } 30 days of code coding problems solutions HackerRank