Skip to content

Commit c584377

Browse files
authored
Add files via upload
1 parent a1d229b commit c584377

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Interface/AbstractClass1.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package Interface;
2+
3+
abstract class Parent {
4+
//optional
5+
Parent()
6+
{
7+
System.out.println("Parent Constructor called");
8+
}
9+
abstract void meth();
10+
//Abstract class can also have final methods
11+
final void meth2()
12+
{
13+
System.out.println("final method called");
14+
}
15+
}
16+
17+
class child extends Parent{
18+
child()
19+
{
20+
System.out.println("Child class constructor called");
21+
}
22+
void meth()
23+
{
24+
System.out.println("abstract method");
25+
}
26+
}
27+
class AbstractClass1 {
28+
public static void main(String[] args) {
29+
child c =new child();
30+
c.meth();
31+
c.meth2();
32+
Parent p=new child();
33+
p.meth();
34+
p.meth2();
35+
36+
}
37+
38+
}

0 commit comments

Comments
 (0)