Write a Java program to display student details using inheritance
import java.io.*; class Student_Details { String name; int roll; String cname; String uname; InputStreamReader in = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(in); void input() throws IOException { System.out.print("Enter Student Name: "); name = br.readLine(); System.out.print("Enter Roll Number: "); roll = Integer.parseInt(br.readLine()); System.out.print("Enter College Name: "); cname = br.readLine(); System.out.print("Enter University Name: "); uname = br.readLine(); } } class Main extends Student_Details { void display() { System.out.print("\n**** Student Details ****\n" ); System.out.print("\nStudent Name: " + name); System.out.print("\nRoll Number: " + roll); System.out.print("\nCollege Name: " + cname); System.out.print("\nUniversity Name: " + uname); } public static void main(String args[]) throws IOException { Main c = new Main(); c.input(); c.display(); } }
Output: