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.
class MyBook{
String title;
void setTitle(String s){
this.title=s;
}
String getTitle(){
return title;
}
}
As we know the abstract classes can support only Declaration ,so we need another class to implement them.Here we use the getters() and setters() to implement them.
-> setters() is used to set the value to variable
-> getters() is used to return a value of variable
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 →
class MyBook{ String title; void setTitle(String s){ this.title=s; }
}
As we know the abstract classes can support only Declaration ,so we need another class to implement them.Here we use the getters() and setters() to implement them.
-> setters() is used to set the value to variable -> getters() is used to return a value of variable