Override Assignment Help

Assignment Help: >> Threads - Override

Override:

Within a class hierarchy, when a method in a subclass has the similar name and type signature as a method in its superclass after that the method in the subclass, subclass is said to override the method in the superclass. Whenever an overridden function is called from inside a subclass, it will always refer to the version of which method defined through the superclass will be hidden consider the subsequent:

// method overriding class A

{

int i,j;

A(int a, int b) { I=a;

J=b;

}

//display i and j void show() {

System.out.println("i and j: " +i " " + j);

}

}

class B extends A{

int k;

B(int a, int b, int c) {

super(a,b);

k=c;

}

// display k - this overrides show() in a

void show() {

System.out.println("k: "+k);

}

}

class override {

public static void main(String a[]) {

B subOb = new b(1,2,3);

SubOb.show();

}

}

The output of this program is

K: 3

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd