Table of Contents

public class Book {

	public String bId,bName;
	public Book(String bId,String bName)
	{
		this.bId=bId;
		this.bName=bName;
	}
	public void display()
	{
		System.out.println("Book ID:"+bId+"\tBook Name:"+bName);
	}
}
public interface Habits {
	public void reading();

}
public abstract class Person {
	public int age;
	public Person(int age)
	{
		this.age=age;
	}
	public abstract void display();

}
public class Student extends Person implements Habits {

	public String id;
	private String name;
	Book book;
	public Student(int age,String id,String name,Book book) {
		super(age);
		this.id=id;
		this.name=name;
		this.book=book;
	}
	public void display()
	{
		System.out.println("Age:"+age);
		System.out.println("ID:"+id+"\tName:"+name);
		
		book.display();
	}
	
	public void reading() {
		System.out.println(name+" Read the Book!");
		
	}
	public static void main(String[] args) {
		Book b1 = new Book("CSE-212","OOP");
		Student s1= new Student(21,"11820","Nurnobi Hosen",b1);
		s1.display();
		s1.reading();
	}
}
Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest
Share on whatsapp
WhatsApp
Share on email
Email
Md. Nurnobi Hosen
Md. Nurnobi Hosen

Student of Computer Science and Engineering at Daffodil International University,Main Campus ,Dhanmondi.
Web and App Developer also expart of wordpress customization

All Blog Posts »
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x