Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suggest another way to take advantage of the dynamic binding in that code. Write the main method to demonstrate the correct functionality of the additions/modifications:

Suggest another way to take advantage of the dynamic binding in that code. Write the main method to demonstrate the correct functionality of the additions/modifications:

************************************

import java.util.*;

class Wk6EllicottG{ public static class Customer{ Scanner userInput = new Scanner(System.in);

//Attributes String name;

//constructor Customer(){ System.out.println("Please enter name: "); name = userInput.nextLine();

}

private void sayHi(){ System.out.println("Hi, " + name + ", I'm the parent class!"); sayHi(); }

public static class Hero extends Customer {

//Attributes

//Constructor Hero(){ sayHi(); }

//override private void sayHi(){ System.out.println("Hi, " + name + ", I'm the Hero class!"); }

} void join(){ Hero newHero = new Hero(); sayHi(); }

}//end customer class

public static void main(String[] args){ Customer test = new Customer.Hero(); //dynamic binding } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Usability

Authors: Jakob Nielsen, Raluca Budiu

1st Edition

0133122131, 9780133122138

More Books

Students also viewed these Programming questions