Question: Use the Java hierarchy you posted in week 3 (corrected based on any feedback you may have received) add one overriding method and one overloading.
Use the Java hierarchy you posted in week 3 (corrected based on any feedback you may have received) add one overriding method and one overloading. The main method should create an instance of the class and demonstrate correct functionality of the overriding and overloading methods. Submit your program as an attached .java file and post a screen shot to show that you have been able to successfully run that program. Make sure you submission adheres to the SubmissionRequirements document.
Code Below:
import java.util.*; import java.lang.*; import java.io.*;
class one_cls { public int s=0; public void print_g() { System.out.println("G for geek "+s); } }
class two_cls extends one_cls { public int o=1; public void print_for() { System.out.println("for "+o); } }
class three_cls extends one_cls { public int t=2; public void print_val() { System.out.println("val "+t); } }
public class Main { public static void main(String[] args) { //creating object three_cls g = new three_cls(); g.print_g(); //creating object two_cls t = new two_cls(); //calling function t.print_for(); //calling function g.print_val(); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
