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.
Java Abstract Class
Java Abstract Class
Sort by
recency
|
194 Discussions
|
Please Login in order to post a comment
FOR BEGGINERS
class MyBook extends Book { void setTitle(String s){ this.title = s; } }
mport java.util.Scanner;
abstract class Book { String title; abstract void setTitle(String s); String getTitle() { return title; } }
class MyBook extends Book { // Implementing the abstract method setTitle void setTitle(String s) { this.title = s; } }
public class Main { public static void main(String[] args) { // Creating an instance of MyBook MyBook myBook = new MyBook();
}
For Begginers
import java.io.; import java.util.; abstract class Book{ String title; abstract void setTitle(String s); String getTitle(){ return title; } } class MyBook extends Book{ public void setTitle(String s) { this.title=s; System.out.println("The title is: "+this.title); } } public class Solution {