Posts

Showing posts from December, 2024

Abtsract class

 import java.util.Scanner; abstract class Book {     String title;     abstract void setTitle(String s);     String getTitle() {         return title;     } } class MyBook extends Book {     @Override     void setTitle(String s) {         this.title = s;      } } public class Main {     public static void main(String[] args) {         Scanner scanner = new Scanner(System.in);         String title = scanner.nextLine();          MyBook new_novel = new MyBook();         new_novel.setTitle(title);          System.out.println("The title is: " + new_novel.getTitle());     } }