-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcwh_53_Abstract.java
54 lines (46 loc) · 1.37 KB
/
cwh_53_Abstract.java
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
package company;
abstract class Parent
{
public Parent()
{
System.out.println("I am a Parent class constructor.");
}
abstract public void greet();
abstract public void greet2();
}
class Child extends Parent
{
@Override
public void greet()
{
System.out.println("Good Morning..");
}
@Override
public void greet2()
{
System.out.println("Good Afternoon..");
}
}
abstract class Child2 extends Parent
{
public void joBhi()
{
System.out.println("Kuch bhi..");
}
}
public class cwh_53_Abstract {
public static void main(String[] args)
{
// Parent p = new Parent(); --error
Child c = new Child();
// Child2 c = new Child2(); --error
/* -Abstract in English means :- existing only in thought or as an idea without concrete existence.
-Abstract Method :- a method that is declared without an implementation.
Ex : abstract public void moveTo(double x, double y);
-Abstract Class :- If a class includes abstract methods, then the class itself must be declared abstract.
When an abstract class is sub-classed, the subclass usually provides implementations for all of the methods in parent class.
If it doesn't, it must be declared abstract.
-Note : It is possible to create reference of an abstract class. But it is not possible to create an object of an abstract class.
*/
}
}