-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabstract_class.java
More file actions
42 lines (33 loc) · 1.17 KB
/
abstract_class.java
File metadata and controls
42 lines (33 loc) · 1.17 KB
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
/*
Definition :-
An abstract class is a class that can not be initialized and used to provide
a comman definition of a base class which can be shared by multiple deriuved class.
-Abstract class can contain both type of method(abstract menthod and concrete method).
-Abstract calss is primerly used as blueprint for other class to follow.
Key features of abstract class:-
1.Object of the abstrat class cannot be iniatilized(It must be inherited by another class).
2.Although abstract class cannot be initilized still they have consturctors that can be called whenever any object of sub-class is created.
*/
//Example
abstract class RAushan{
abstract void sound();
void fun1() {
System.out.println("RAushan's code executed successfully.");
}
}
class Parker extends RAushan {
void fun2() {
System.out.println("The Parker is good.");
}
@Override
void sound() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
public class Main {
public static void main(String[] args) {
Parker parker = new Parker();
parker.fun2();
parker.fun1();
}
}