We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
importjava.util.*;abstractclassBook{Stringtitle;abstractvoidsetTitle(Strings);StringgetTitle(){returntitle;}}classMyBookextendsBook{//String title;voidsetTitle(Strings){this.title=s;}StringgetTitle(){returntitle;}}publicclassMain{publicstaticvoidmain(String[]args){//Book new_novel=new Book(); This line prHMain.java:25: error: Book is abstract; cannot be instantiatedScannersc=newScanner(System.in);Stringtitle=sc.nextLine();MyBooknew_novel=newMyBook();new_novel.setTitle(title);System.out.println("The title is: "+new_novel.getTitle());sc.close();}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Abstract Class
You are viewing a single comment's thread. Return to all comments →