-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathProgram_12.java
33 lines (28 loc) · 946 Bytes
/
Program_12.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.Scanner;
// WAP to show single level inheritance.
class ParentClass1{
String name;
int rollNo;
ParentClass1(){
System.out.println("This is class 'test'.\n");
}
}
public class Program_12 extends ParentClass1 {
float grades;
public void display(){
System.out.println("\nName of the student: " + name);
System.out.println("Roll no. of the student: " + rollNo);
System.out.println("Grades of the student: " + grades);
}
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
Program_12 ob = new Program_12();
System.out.print("Enter name of the student: ");
ob.name = cin.next();
System.out.print("Enter Roll number: ");
ob.rollNo = cin.nextInt();
System.out.print("Enter grades: ");
ob.grades = cin.nextFloat();
ob.display();
}
}