Rabu, 08 Maret 2017

How to refer super class members in Java

Second use of super keyword (in sub class) is to access the hidden members of its immediate super class. To understand this let’s consider the following example: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 class A { int x; public void display() { System.out.println(“This is display in A”); } } class B extends A { int x; public void display() { System.out.println(“Value of x in A is: “ + super.x); super.display(); System.out.println(“This is display in B”); } } class Driver {

The post How to refer super class members in Java appeared first on Coding Security.


How to refer super class members in Java
read more

Tidak ada komentar:

Posting Komentar