Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- abstract class Person {
- String name;
- public Person(String name) {
- this.name = name;
- }
- int foo () {
- return 0;
- }
- }
- class Employee extends Person {
- public Employee(String name) {
- super(name);
- }
- @Override
- int foo() {
- return 1;
- }
- }
- class Client extends Person {
- public Client(String name) {
- super(name);
- }
- @Override
- int foo() {
- return 2;
- }
- }
- public class Main {
- public static void main(String[] args) {
- Person Tomek = new Employee("Tomek");
- Person Adam = new Client("Adam");
- System.out.println(Adam.foo());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement