Created
September 22, 2020 12:18
-
-
Save mrnirva/e65b9631889d5b66c58e54a217a537f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package inheritance; | |
public class Kalitim { | |
public static void main(String[] args) { | |
// Her iki sınıftanda nesne oluşturduk | |
Arac arac = new Arac(); | |
Kamyon kamyon = new Kamyon(); | |
// yazdir metodunu çağırdık | |
arac.yazdir(); | |
kamyon.yazdir(); | |
// Araç sınıfının özelliğini kamyon için kullanabildik | |
kamyon.tekerler = 5; | |
System.out.println(kamyon.tekerler); | |
} | |
} | |
class Arac{ | |
public int tekerler; | |
void yazdir(){ | |
System.out.println("Araç Sınıfı"); | |
} | |
} | |
class Kamyon extends Arac{ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment