-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoops.java
More file actions
35 lines (35 loc) · 949 Bytes
/
oops.java
File metadata and controls
35 lines (35 loc) · 949 Bytes
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
34
35
import java.util.*;
class Person{
String name;
int age;
Person(String name , int age){
this.name=name;
this.age=age;
// System.out.println(this.name+"\t"+this.age);
}
Person(){
System.out.println("default constructor calling...");
}
void display(){
System.out.println(this.name+"\t"+this.age);
}
}
class Student extends Person{
int marks;
Student(String name, int age , int marks){
super(name,age);
this.marks = marks;
}
@Override
void display(){
System.out.println(this.name+"\t"+this.age+"\t"+this.marks);
}
}
class main{
public static void main(String args[]){
// Student s = new Student("Mayank",21,10);
// s.display();
// Person p = new Student("Mayank",21,10);
// p.display();
}
}