Write a Java program to print student details using single inhiritance concept

Write a Java program to print student details using single inhiritance concept

Program
import java.util.*;
class A
{
    String name,location,address;
    char gender;
}

class Student extends A
{
    String id;
    float marks,fee;
    Student()
    {
        Scanner s=new Scanner(System.in);
        System.out.println("Enter name : ");
        name=s.next();
        System.out.println("Enter location : ");
        location=s.next();
        System.out.println("Enter address : ");
        address=s.next();
        System.out.println("Enter gender: ");
        gender=s.next().charAt(0);
        System.out.println("Enter id : ");
        id=s.next();
        System.out.println("Enter marks : ");
        marks=s.nextFloat();
        System.out.println("Enter fee : ");
        fee=s.nextFloat();
    }
    void studentDetails()
    {
        System.out.println("Name of the student is :"+name);
        System.out.println("location of the student is : "+location);
        System.out.println("Address of the student is : "+address);
        System.out.println("Gender of the student is : "+gender);
        System.out.println("Student id is : "+id);
        System.out.println("Marks of the student is : "+marks);
        System.out.println("Student Fee is : "+fee);
    }
}
public class Main
{
    public static void main(String args[])
    {
        Student st=new Student();
        st.studentDetails();
    }
}

Output:

Enter name : sateesh
Enter location : Hyd
Enter address : kukatpally
Enter gender : M
Enter id : 1224
Enter marks : 98
Enter fee : 1000

Name of the student is : sateesh
location of the student is : Hyd
Address of the student is : kukatpally
Gender of the student is : M
Student id is : 1224
Marks of the student is : 98.0
Student Fee is : 1000.0

Inheritance In Java



More Questions


132 . Write a Java-program with using this()
133 . Write a Java program to print student details using single inhiritance concept
134 . Write a Java program to print student details using multilevel inhiritance concept
135 . Write a Java program to print student and faculty details using hirarchy inhiritance concept
136 . Write a Java program with out using abstract keyword
137 . Write a Java program with using abstract keyword
138 . Abstract Practice Program 1
139 . Write a Java program to create object for abstract class
140 . Abstract Practice Program 2
141 . Abstract Practice Program 3
142 . Abstract Practice Program 4