-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPhone.java
More file actions
34 lines (23 loc) · 696 Bytes
/
Phone.java
File metadata and controls
34 lines (23 loc) · 696 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
package com.tyss.inheritance;
public class Phone {
/*Super class*/
/*if we doesn't provide constructor the jvm provides the default constructor.
* acquiring the properties and behavior from one class to another class is known as inheritance by using the keyword extends.
* why using inheritance because code reusability */
int price;
int ram;
public Phone(int p,int r) {
price=p;
ram=r;
System.out.println("super class loaded");
}
public void call(String name) {
System.out.println(name+"calling");
}
public void message(String msg) {
System.out.println(msg);
}
public void radio() {
System.out.println("playing pogathae pogathae ........");
}
}