-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClass_Type_Casting2.java
More file actions
60 lines (55 loc) · 872 Bytes
/
Copy pathClass_Type_Casting2.java
File metadata and controls
60 lines (55 loc) · 872 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package basicprograms;
class Super_Casting{
static void add()
{
System.out.println(1);
}
static void subtract()
{
System.out.println(2);
}
void multiply()
{
System.out.println(3);
}
void divide()
{
System.out.println(4);
}
}
public class Class_Type_Casting2 extends Super_Casting{
static void method1()
{
System.out.println(5);
}
static void method2()
{
System.out.println(6);
}
void method3()
{
System.out.println(7);
}
void method4()
{
System.out.println(8);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
//Upcasting
Super_Casting s1=new Class_Type_Casting2();
add();
subtract();
s1.multiply();
s1.divide();
Class_Type_Casting2 c1=(Class_Type_Casting2) s1;
method1();
method2();
c1.method3();
c1.method4();
c1.multiply();
c1.divide();
add();
subtract();
}
}