Develop a java program to create a class "Book" having data members 'author', 'title', & 'publisher'. Derive a class "BookInfo" having data members 'price', 'stock position' and a method 'show()'. Initialize and display the information for 3 objects of "BookInfo".

class Book
{
 String author, title, publisher;
 Book(String a, String t, String p)
 {
  author = a;
  title = t;
  publisher = p;
 }
}
class BookInfo extends Book
{
 float price;
 int stock_position;
 BookInfo(String a, String t, String p, float amt, int s)
 {
  super(a, t, p);
  price = amt;
  stock_position = s;
 }
 void show()
 {
  System.out.println("Book Details:");
  System.out.println("Title: " + title);
  System.out.println("Author: " + author);
  System.out.println("Publisher: " + publisher);
  System.out.println("Price: " + price);
  System.out.println("Stock Available: " + stock_position);
 }
}
class Exp6_1
{
 public static void main(String[] args) 
 {
  BookInfo ob1 = new BookInfo("Herbert Schildt", "Complete Reference", "ABC Publication", 2359.50F, 10);
  BookInfo ob2 = new BookInfo("Ulman", "system programming", "XYZ Publication", 359.50F, 20);
  BookInfo ob3 = new BookInfo("Pressman", "Software Engg", "Pearson Publication", 879.50F, 15);
  ob1.show();
  ob2.show();
  ob3.show();
 }
}
/*  OUTPUT!!!
Book Details:
Title: Complete Reference
Author: Herbert Schildt
Publisher: ABC Publication
Price: 2359.5
Stock Available: 10
Book Details:
Title: system programming
Author: Ulman
Publisher: XYZ Publication
Price: 359.5
Stock Available: 20
Book Details:
Title: Software Engg
Author: Pressman
Publisher: Pearson Publication
Price: 879.5
Stock Available: 15
*/
Copyright © LetML. Blogger Templates Designed by OddThemes