forked from rick2785/JavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCat2.java
More file actions
30 lines (17 loc) · 580 Bytes
/
Cat2.java
File metadata and controls
30 lines (17 loc) · 580 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
public class Cat2 extends Animal2{
// The constructor initializes all objects
public Cat2(){
// Executes the parents constructor
// Every class has a constructor whether you make it or not
super();
// Sets bark for all Dog objects by default
setSound("Meow");
}
// If you want to make sure a method isn't overridden mark it as Final
final void attack(){
// Do stuff that can never change
}
// A field marked with final can't be changed
public static final double FAVNUMBER = 3.14;
// A class labeled as final can't be extended
}