override java
// A Simple Java program to demonstrate
// method overriding in java
// Base Class
class Parent {
void show()
{
System.out.println("Parent's show()");
}
}
// Inherited class
class Child extends Parent {
// This method overrides show() of Parent
@Override
void show()
{
System.out.println("Child's show()");
}
}
// Driver class
class Main {
public static void main(String[] args)
{
// If a Parent type reference refers
// to a Parent object, then Parent's
// show is called
Parent obj1 = new Parent();
obj1.show();
// If a Parent type reference refers
// to a Child object Child's show()
// is called. This is called RUN TIME
// POLYMORPHISM.
Parent obj2 = new Child();
obj2.show();
}
}
Also in Java:
- java valeur absolue
- convert integer array to string array
- eclipse does not support logback with spring boot
- java check if file exists
- how to set frame colo in java
- Kotlin is like java
- cannot fit requested classes in a single dex file
- random code
- get drawable with string android java
- sc.nextline skips
- how to delete character in string java
- android recyclerview show hide item with animation with default animation
- primitive and non primitive data types in java
- java try catch
- spring framework iterate
- Please ensure that your JAVA_HOME points to a valid Java SDK. You are currently pointing to: /usr/lib/jvm/java-13-oracle
- how to append to an array in java
- how to multiply a number by itself using for loop in java
- java stack push
- how to stop a void java
- java get icon for file type
- StringBuilder java pop back
- how to do substring java
- processing pi