-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabstract-class.html
148 lines (113 loc) · 4.69 KB
/
abstract-class.html
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<!--
~ Author: @tridib2003
~ Repository: https://github.com/tridib2003/levelupjava
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Abstract Class | Level-Up Java</title>
<link href="styles.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<nav class="navigation-std">
<ul class="ul-remove-bullet nav-pills">
<li class="ul-inline-item nav-pills-decor">
<a class="link" href="/">Previous</a>
</li>
<li class="ul-inline-item nav-pills-decor">
<a class="link" href="/">Home</a>
</li>
<li class="ul-inline-item nav-pills-decor">
<a class="link" href="/">Next</a>
</li>
</ul>
</nav>
<h1 class="h1-basic">Abstract Class</h1>
<div class="desc-container desc-container-center desc-std">
<hr>
<ul>
<li>
<p>
A superclass that declares the generalized form of a given abstraction without providing the
complete implementation for every method, can be inherited by a subclass inorder to provide a
meaningful implementation. Basically the superclass defines a generalized form that will be shared
by all of its subclasses. This is where <strong>abstract methods</strong> come into picture.
</p>
</li>
<li>
<p>
<strong>Abstract methods</strong> of a superclass must be overridden by subclasses providing their
meaningful implementations. Abstract methods are thus referred to as <i>subclasser
responsibility</i>, as the subclass has to provide the implementation of the abstract methods of
its superclass. A subclass must implement all of the abstract methods present in its superclass, or
must be declared abstract itself.
</p>
</li>
<li>
<p>
A class containing abstract methods must also be declared abstract using the
<strong>abstract</strong> keyword.
</p>
</li>
<li>
<p>
An <strong>abstract class</strong> cannot be instantiated. This totally makes sense because an
abstract class contains methods that don't have their implementations. Although they can be used to
create object references in order to implement run-time polymorphism through the use of superclass
references.
</p>
</li>
<li>
<p>
An <strong>abstract class</strong> can have methods with complete implementation.
</p>
</li>
<li>
<p>
We cannot declare abstract constructors, or abstract static methods.
</p>
</li>
</ul>
</div>
<br><br><br>
<div class="table-container table-container-center">
<table class="table-code-links">
<tr>
<td>
Demonstrate an <strong>abstract class</strong>
</td>
<td>
<div class="btn-container-center">
<a class="btn-link btn-link-color1"
href="https://github.com/tridib2003/levelupjava-wiki/blob/main/Abstract%20Class/AbstractClassDemo.java"
target="_blank">
<i class="fa fa-github" style="font-size: 18px; color: whitesmoke;">
<p style="display: inline; margin-left: 0.4rem;">
View code
</p>
</i>
</a>
</div>
</td>
</tr>
</table>
</div>
<br><br><br>
<footer class="navigation-std">
<ul class="ul-remove-bullet nav-pills">
<li class="ul-inline-item nav-pills-decor">
<a class="link" href="/">Previous</a>
</li>
<li class="ul-inline-item nav-pills-decor">
<a class="link" href="/">Home</a>
</li>
<li class="ul-inline-item nav-pills-decor">
<a class="link" href="/">Next</a>
</li>
</ul>
</footer>
</body>
</html>