super keyword

With a super keyword, you have access(reference) to your parent class. In addition to super, you benefit invoking the methods, variables of the parent class.


public class A  extends B{

	A(int a,int b) {
		super(a, b);
} }
public class B {
private int a;
private int b;
	B(int a,int b){
		this.b = b;
	public int getA() {
		return a;
	public void setA(int a) {
		this.a = a;
public class Main {

	public static void main(String[] args) {
	A A_Class = new A(2,2);



Output is: 2

Leave a Reply

Your email address will not be published. Required fields are marked *