Skip to content

Commit 6227ab1

Browse files
author
JavaProgramTo.com
committed
Java Extends Keyword
1 parent 4c45ad2 commit 6227ab1

File tree

4 files changed

+85
-2
lines changed

4 files changed

+85
-2
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.javaprogramto.keywords.extend;
2+
3+
public class ClasesExtendsExamples {
4+
5+
public static void main(String[] args) {
6+
7+
HondaCar hondaCar = new HondaCar();
8+
int noOfWheels = hondaCar.getNoOfWheels();
9+
System.out.println("Honda car wheels : " + noOfWheels);
10+
11+
}
12+
}
13+
14+
class Car {
15+
16+
int noOfWheels = 4;
17+
}
18+
19+
class HondaCar extends Car {
20+
21+
public int getNoOfWheels() {
22+
return this.noOfWheels;
23+
}
24+
}
25+
26+
class HybridCar extends Car , HondaCar{
27+
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.javaprogramto.keywords.extend;
2+
3+
public class ClasesExtendsExamples {
4+
5+
public static void main(String[] args) {
6+
7+
HondaCar hondaCar = new HondaCar();
8+
int noOfWheels = hondaCar.getNoOfWheels();
9+
System.out.println("Honda car wheels : " + noOfWheels);
10+
11+
}
12+
}
13+
14+
class Car {
15+
16+
int noOfWheels = 4;
17+
}
18+
19+
class HondaCar extends Car {
20+
21+
public int getNoOfWheels() {
22+
return this.noOfWheels;
23+
}
24+
}
25+
26+
class HybridCar extends Car , HondaCar{
27+
28+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.javaprogramto.keywords.extend;
2+
3+
public class InterfaceExtendsExamples {
4+
5+
public static void main(String[] args) {
6+
7+
8+
}
9+
}
10+
11+
12+
interface Payment {
13+
14+
boolean processPayment();
15+
16+
}
17+
18+
interface CreditCardPayment extends Payment{
19+
20+
void validateCardDetails();
21+
}
22+
23+
interface UPIPayment extends Payment{
24+
25+
void validateUPIAddress();
26+
}

src/main/java/com/javaprogramto/keywords/finals/FinalClassExample.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public void sayHelloWorld() {
1414
System.out.println("hello world");
1515
}
1616
}
17-
17+
/*
1818
class JavaProgamTo extends Java {
1919
20-
}
20+
}
21+
*/

0 commit comments

Comments
 (0)