这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions core-java-modules/core-java-lang-oop-inheritance-2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Core Java Lang OOP - Inheritance

This module contains articles about inheritance in Java

### Relevant Articles:
- [Upcasting Vs. Downcasting in Java](https://www.baeldung.com/java-upcasting-vs-downcasting)
- More articles: [<-- prev](https://github.com/eugenp/tutorials/tree/master/core-java-modules/core-java-lang-oop-inheritance)
16 changes: 16 additions & 0 deletions core-java-modules/core-java-lang-oop-inheritance-2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-lang-oop-inheritance-2</artifactId>
<packaging>jar</packaging>
<name>core-java-lang-oop-inheritance-2</name>

<parent>
<artifactId>core-java-modules</artifactId>
<groupId>com.baeldung.core-java-modules</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>

</project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.baeldung.upcastingvsdowncasting;
class Animal {
public void makeSound() {
System.out.println("Animal sound");
}
}
package com.baeldung.upcastingvsdowncasting;

class Animal {
public void makeSound() {
System.out.println("Animal sound");
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.baeldung.upcastingvsdowncasting;

class Dog extends Animal {
public void makeSound() {
System.out.println("Bark");
}

public void fetch() {
System.out.println("Dog fetches");
}
}
package com.baeldung.upcastingvsdowncasting;

class Dog extends Animal {

@Override
public void makeSound() {
System.out.println("Bark");
}

public void fetch() {
System.out.println("Dog fetches");
}
}
2 changes: 1 addition & 1 deletion core-java-modules/core-java-lang-oop-inheritance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ This module contains articles about inheritance in Java
- [Object Type Casting in Java](https://www.baeldung.com/java-type-casting)
- [Variable and Method Hiding in Java](https://www.baeldung.com/java-variable-method-hiding)
- [Inner Classes vs. Subclasses in Java](https://www.baeldung.com/java-inner-classes-vs-subclasses)
- [Upcasting Vs. Downcasting in Java](https://www.baeldung.com/java-upcasting-vs-downcasting)
- More articles: [next -->](https://github.com/eugenp/tutorials/tree/master/core-java-modules/core-java-lang-oop-inheritance-2)