Sort by

recency

|

209 Discussions

|

  • + 0 comments

    Java abstract classes are powerful tools to design flexible and reusable code. They allow developers to define a blueprint for related classes, enforcing specific behaviors (via abstract methods) while sharing common functionality (via concrete methods). Cricbet99 Green

  • + 0 comments

    Here is Java Abstract Class solution - https://programmingoneonone.com/hackerrank-java-abstract-class-problem-solution.html

  • + 0 comments

    import java.util.*; abstract class Book{ String title; abstract void setTitle(String s); String getTitle(){ return title; }

    } final class MyBook extends Book{ void setTitle(String title2){ this.title = title2; } } public class Main{

    public static void main(String []args){
        //Book new_novel=new Book(); This line prHMain.java:25: error: Book is abstract; cannot be instantiated
        Scanner sc=new Scanner(System.in);
        String title=sc.nextLine();
        MyBook new_novel=new MyBook();
        new_novel.setTitle(title);
        System.out.println("The title is: "+new_novel.getTitle());
        sc.close();
    
    }
    

    }

  • + 1 comment

    Tried this useless platform after a while and remembered why I left. Retards here never realized one is not supposed to put solution in discussion.

  • + 0 comments

    public class Solution {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner scan = new Scanner(System.in);
        MyBook myBook = new MyBook();
        String title = scan.nextLine();
        myBook.setTitle(title);
        System.out.println("The title is: "+myBook.getTitle());
    }
    

    }

    abstract class Book{ String title; abstract void setTitle(String s); String getTitle(){ return title; } }

    class MyBook extends Book{ @Override void setTitle(String s){ super.title = s; } }