Learn the Java super keyword in 10 minutes! πŸ” @BroCodez
Learn the Java super keyword in 10 minutes! πŸ”  @BroCodez
Uploaded December 2024 | Updated September 2026, 2 weeks ago
#java #javatutorial #javacourse

public class Main {
public static void main(String[] args) {

// super = Refers to the parent class
// Used in constructors and method overriding
// Calls the parent constructor to initialize attributes

Person person = new Person("Tom", "Riddle");
Student student = new Student("Harry", "Potter", 3.25);
Employee employee = new Employee("Rubeus", "Hagrid", 50000);

}
}

public class Person {

String first;
String last;

Person(String first, String last){
this.first = first;
this.last = last;
}

void showName(){
System.out.println(this.first + " " + this.last);
}
}

public class Student extends Person{

double gpa;

Student(String first, String last, double gpa){
super(first, last);
this.gpa = gpa;
}

void showGPA(){
System.out.println(this.first + "'s gpa is: " + this.gpa);
}
}

public class Employee extends Person{

int salary;

Employee(String first, String last, int salary){
super(first, last);
this.salary = salary;
}

void showSalary(){
System.out.println(this.first + "'s salary is $" + this.salary);
}
}
Learn the Java super keyword in 10 minutes! πŸ”Lets code a circle calculator program with C βšͺMongoDB comparison operators explainedMatplotlib pie charts in 6 minutes! πŸ₯§Learn function prototypes in 5 minutes! πŸ“ŒJava hashmaps are easy! πŸ—ΊοΈLearn variable scope in 5 minutes! 🏠Useful string methods in Java! 🧡Switches in C are easy! πŸ’‘DataFrames in Pandas are easy! πŸ”’Convert decimal to binary EASY! #computerscience #coding #programmingLearn Java getters and setters in 10 minutes! πŸ”
Bro Code |

Learn the Java super keyword in 10 minutes! πŸ”

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER