Knowledge Walls
John Peter
Pune, Maharashtra, India
What are all ways to use super keyword in java with example
They are three purpose to use super keyword.

1. To call super class constructors from sub class constructors.

2. To access super class member variables. This is not accessible by sub class If sub class has the same variable name otherwise super.
   super.variable_name = 10;

3. To call super class methods. This is not accessible by sub class If sub class has the same method name which is in super class.
class Cricket {
    int runs;
    int over;
    public Cricket(){
        over = 99;
    public void display(){
        System.out.println("Runs: "+runs+";Over: "+over);

class CricketCounter extends Cricket{
    public CricketCounter(){
    public void display(){
        super.runs = 82;

class Solution {
    public static void main(String args[])throws Exception{
        CricketCounter cric = new CricketCounter();
Runs: 82;Over: 99
Previous Topics
Previous lessons of current book.
Computer software engineer articles of One day One Thing to Know
Best Lessons of "One day One Thing to Know"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details