- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEveryClassExtendsObject.java
More file actions
Latest commit
26 lines (20 loc) · 787 Bytes
/
Copy pathEveryClassExtendsObject.java
File metadata and controls
26 lines (20 loc) · 787 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
packageClassAndObjects;
//Every Java class extends Object class
publicclassEveryClassExtendsObject {
publicvoidtestMethod() throwsCloneNotSupportedException {
// toString,hashCode,clone methods are
// inherited from Object class
System.out.println(this.toString());
System.out.println(this.hashCode());
System.out.println(this.clone());
}
publicstaticvoidmain(String[] args) throwsCloneNotSupportedException {
EveryClassExtendsObjectexample1 = newEveryClassExtendsObject();
EveryClassExtendsObjectexample2 = newEveryClassExtendsObject();
if (example1instanceofObject) {
System.out.println("I extend Object");// Will be printed
}
// equals method is inherited from Object class
System.out.println(example1.equals(example2));// false
}
}