• Beranda
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.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Java
  3. Object Oriented Programming
  4. Java Abstract Class
  5. Discussions

Java Abstract Class

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 148 Discussions, By:

recency

Please Login in order to post a comment

  • suhithaambati
    2 days ago+ 0 comments

    class MyBook extends Book { void setTitle(String s) { title=s;

    }
    

    }

    0|
    Permalink
  • csennn
    2 weeks ago+ 0 comments

    here is the simple solution https://github.com/csennn/java_abstract_class/blob/main/codes

    0|
    Permalink
  • chailrana2001
    3 weeks ago+ 0 comments

    import java.io.; import java.util.;

    public class Solution {

    public static void main(String []args){
        //Book new_novel=new Book();  Abstract cass cannot be instantiated like this
        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());
    
    }
    

    }

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

    class MyBook extends Book{ void setTitle(String s){ title=s; } }

    0|
    Permalink
  • poonamdeorasurp1
    1 month ago+ 0 comments

    Here is problem solution - https://thecscience.com/hackerrank-java-abstract-class-problem-solution.html

    0|
    Permalink
  • e_mm_u
    2 months ago+ 0 comments

    The problem and what we need to do is defined nicely. As the abstract class is given we have to create MyBooks class that extends the abstract class. Now, as this is a child class, it will inherit all the properties of super class. So, I've just defined the body of the setTitle method here. And it's all.

    //Write MyBook class here
    class MyBook extends Book{
        void setTitle(String s){
            title = s;
        }
    }
    
    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy